Posted in 面试题 onApril 15, 2016
解: #include
main()
{ int upper=0.lower=0,digit=0,space=0,other=0,i=0;
char *p,s[20];
printf(“Input string:”);
while ((s[i]=getcher())!=’\n’) i++;
p=&s[0];
while(*p!=’\n’)
{ if((‘A’ ++upper;
else if((‘a’ ++lower;
else if(8p= =’’)
++space;
else if((*p=’0’))
++dight;
else
++other;
p++;
}
printf(“upper case:%d lower case:%d”,upper,lower);
printf(“space:%d\ndigit:%d\nother:%d\n”,space,digit,other);
}
main()
{ int upper=0.lower=0,digit=0,space=0,other=0,i=0;
char *p,s[20];
printf(“Input string:”);
while ((s[i]=getcher())!=’\n’) i++;
p=&s[0];
while(*p!=’\n’)
{ if((‘A’ ++upper;
else if((‘a’ ++lower;
else if(8p= =’’)
++space;
else if((*p=’0’))
++dight;
else
++other;
p++;
}
printf(“upper case:%d lower case:%d”,upper,lower);
printf(“space:%d\ndigit:%d\nother:%d\n”,space,digit,other);
}
输入一行文字,找出其中大写字母、小写字母、空格、数字、及其他字符各有多少
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Tags in this post...
Reply on: @reply_date@
@reply_contents@