#include <iostream>
#include <math.h>

#define ep 1e-10

void printWithSpace(int a, int nos) {
	char s[100];
	int size = (int)(log(a) / log(10)) + 1;
	int i = size - 1;
	s[size] = '\0';
	while (i >= 0) {
		s[i--] = a % 10 + '0';
		a /= 10;
	}
	nos--;
	for (i = 0; i < size; i++) {
		std::cout << s[i];
		if (nos) {
			std::cout << ' ';
			nos--;
		}
	}
	std::cout << std::endl;
}

void printWithSpace(double f, int nos) {
	int a = (int)f;
	double b = f - a;
	char s[100];
	int i = (int)(log(a) / log(10));
	s[i + 1] = '.';
	int j = i + 2;
	while (i >= 0) {
		s[i--] = a % 10 + '0';
		a /= 10;
	}
	while (b > ep) {
		b *= 10.0;
		s[j++] = (int)b + '0';
		b -= (double)(int)b;
	}
	s[j] = '\0';
	nos--;
	for (i = 0; i < j; i++) {
		std::cout << s[i];
		if (nos) {
			std::cout << ' ';
			nos--;
		}
	}
	std::cout << std::endl;
}

int main() {
	printWithSpace(67514, 4);
	printWithSpace(123.456, 4);
	return 0;
}
