我同事写的 ,有些语句有点不明白其功能,新手,有愿意指点的高手,我祝你们新年大发!
输入n位整数,将其每位数字分割打印。#include <stdio.h>
int main()
{
long integerLength=0,integerLength2=0;
long tempNumber=0,Number=0;
long tempT;
printf("enter a integer:");
scanf("%d",&Number);
tempNumber=Number;
while(tempNumber>0)
{
integerLength++;
tempNumber=tempNumber/10;
}
while(integerLength>0)
{
integerLength2=integerLength;
tempT=1;
while(--integerLength2>0)
{
tempT=tempT*10;
}
printf("%d ",Number/tempT);
Number=Number-Number/tempT*tempT;
integerLength--;
tempT=0;
}
getchar();
getchar();
}