Preview:
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>

using namespace std;




string format(int number, int width);
int numberWidthF(int number);

int main()
{

	
	int number,width;
	cin >> number >> width;
	cout << format(number, width);
	
}
string format(int number, int width)
{
	string zeros = " ";
	string num = to_string(number);
	
	int numberWidth = numberWidthF(number);
	
	for (int  i = 1; i <= width-numberWidth; i++)
	{
		zeros += "0";
	}
	return zeros+num;
}
int numberWidthF(int number)
{
	int digits, numberWidth = 0;
	while (number != 0)
	{
		digits = number % 10;
		number /= 10;
		numberWidth++;
	}
	return numberWidth;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter