scanf("%d",&num[i]);
↓
scanf("%c",&num[i]);
if(a!=2 || b!=4 )
↓
if(a!=2 || b!=4 )
↓
scanf("%c",&num[i]);
if(a!=2 || b!=4 )
↓
if(a!=2 || b!=4 )
程序代码:
#include <stdio.h> #include <ctype.h> int main() { char num[6]; int i,a=0,b=0; printf("Please input your number:\n"); for (i=0; i<6; i++) scanf("%c", &num[i]); for (i=0; i<2; i++) { if(isalpha(num[i])) a++; } for (i=2; i<6; i++) { if(isdigit(num[i])) b++; } if (a!=2 || b!=4 ) printf("Wrong!"); else printf("Right!"); return 0; }
[此贴子已经被作者于2016-6-19 17:06编辑过]