输入不足的地方用0占位

#include <iostream>
using namespace std;

void main()
{
	for(int i = 1; i <= 35; i++)
	{
		char str[20];
		sprintf(str, "%03d", i);
		cout<<str<<endl;
	}
}

/*
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
*/

你可能感兴趣的:(输入不足的地方用0占位)