6.3w+
社区成员
#include <stdio.h>
int main( void )
{
int i;
for ( ; ; )
{
fputs("Please input an integer: ", stdout);
scanf("%d", &i);
printf("%d\n", i);
}
return 0;
}
#include <stdio.h>
#include <iostream>
void main()
{
int x, c;
while ( 1 )
{
printf("Please input a integer:\n");
scanf("%d",&x);
if ( x>=1000 || x<=0 )
printf("The number you input is invalid.\n");
else if ( x >= 100 )
printf("The number has 3 digits.\n");
else if ( x >= 10 )
printf("The number has 2 digits.\n");
else
printf("The number has 1 digit.\n");
while ( (c = getchar()) != '\n' && c != EOF ) ;//<====There~
}
return;
}
#include <stdio.h>
int main()
{
int x;
while (1)
{
printf("Please input a integer:\n");
scanf("%d", &x);
if (x>=1000 || x <=0)
printf("The number you input is invalid.\n");
else if (x >= 100)
printf("The number has 3 digits.\n");
else if (x >= 10)
printf("The number has 2 digits.\n");
else
printf("The number has 1 digit.\n");
fflush(stdin); //清空一下缓冲区就好了
}
return 0;
}