/*
092134179x:输入错误,继续输入,'#'结束
21344009764x:输入错误,继续输入,'#'结束
09213417921344009764
Press any key to continue
*/
#include
#include
int main()
{ char ch = 0,s[36];
int i = 0;
while(1) {
ch = getch();
if(ch >= '0' && ch <= '9' && i < 35) {
s[i++] = ch;
putchar(ch);
}
else if(ch == '#') {
s[i++] = '\0';
break;
}
else {
printf("x:输入错误,继续输入,'#'结束\n");
continue;
}
}
printf("%s\n",s);
return 0;
}
#include
main()
{
int a;
printf("input an integer:\n");
scanf("%d",&a);
for(;a!=0&&a!=1&&a!=2;)
{ printf("input error,repeat:\n");
scanf("%d",&a);
}
printf("\ninput correct");
}
int a;printf("input a num:");
while(scanf("%d",&a)!=1||a!=0&&a!=1&&a!=2)
{printf("error,input again:");
while(getchar()!='\n');}