回复 楼主 才在学
#include<stdio.h>
#define wnum 4
int main()
{
int fnum = 0;
int tnum = 0;
int count = 0;
printf("请键入一个四位整数:\n");
while(scanf("%d",&fnum) != 1 || (fnum < 1111 || fnum > 9999))
{
printf("你键入了错误的信息,请重新键入:\n");
while(getchar() != '\n');
}
while((++count) < wnum)
{
tnum += fnum%10;
fnum = fnum/10;
}
tnum = tnum + fnum;
printf("四位整数,各位相加之和为:%d\n",tnum);
system("pause");
return 0;
}
不说是标准,但是很全面,运行中不会产生引错误而停止。。。