...遇到非4位的要在前面添“0” 如:1 01 001 0001)
发布网友
发布时间:2024-09-29 08:47
我来回答
共1个回答
热心网友
时间:2024-10-29 20:46
#include<stdio.h>
void main()
{
int index = 0;
int iter = 0;
for( index = 0; index < 10000; index ++ )
{
for( iter = 0; iter < 4; iter ++)
{
if( index/1000)
{
printf("%4d\n",index);
printf("%4d\n",index);
printf("%4d\n",index);
printf("%4d\n",index);
}
elseif( index/100)
{
printf("%4d\n",index);
printf("%4d\n",index);
printf("%4d\n",index);
printf("0%4d\n",index);
}
elseif( index/10)
{
printf("%4d\n",index);
printf("%4d\n",index);
printf("0%4d\n",index);
printf("00%4d\n",index);
}
else
{
printf("%4d\n",index);
printf("0%4d\n",index);
printf("00%4d\n",index);
printf("000%4d\n",index);
}
}
}
}