c语言程序题。用循环控制语句
编写程序,从键盘上输入一串字符,以回车结束,输出其中大写字母,小写字母,数字字符和其他字符的个数。
1回答
-
望远
#include<stdio.h>
void main()
{
char str[100];
int i,number=0,A=0,a=0,other=0;
printf("请输入一行字符串:");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]>='0'&&str[i]<='9')
number++;
else if(str[i]>='a'&&str[i]<='z')
a++;
else if(str[i]>='A'&&str[i]<='Z')
A++;
else
other++;
}
printf("大写字母:%d个,小写字母:%d个,数字:%d个,其他%d个\n",
A,a,number,other);
}
-
慕瓜9220888
JAJQFLKXKPXKFEEXQTHZHJILONALDONZYLRHKLDPRRANXEONFXQGDPIJOTYBEORQLDMICLOXFNVAPJVLIIJLXPFRBXLGYGLILKHIMVNVEXXACFEPEHKDQYZHJOUBEAQFNWFMDTETUJRDJWBUWBMLGZYXKXVXMEHIRUOCUPMZILFFMNYQGTTZXPVKUQGTJTKRTSEXRAQUZRDMCYLOPODNTJMFZAFHREUNDJAZRKRUXKEYNPAAAWMEONBJPVVYGCBMRYHKUGDPHPMFSRQXGEMPCMAQZBQVPVYKKOQODWJMMXYQZBDNJGBCKMFNAJGLWIGHDWMJQVBNMSLIORSOZBLEXXJKDWREXANCDMEWPFLFABWRRXUEAQHMECMZLVLMBMWCWVINUJLQJILIRCASKNKGTRSRCBUEQNVMRJVLERBJUMBJTBBHTAZNLIZVDKVRGBEUKQDYEQTYVEOBTJYATCWMYVUQFOHUUGXWETAJGPRWBMLOOUNECUGEENAKYZEDIVERBVWBNBYBRXYIHZHURJSHOJFGAQOOOPENYDJQGPAIRSZPLRZAVXFIFYEJYZBGNTZSRCKJKUDKCQEJGILLHRKBTGIBBUOMNCPHRDTAUTOAISEEHODBTLREHHJKJLJMZPFSQFYHBYVCGUCYGWJCVYWHDYJPFVPMVXIILORLDBTCFRRYDEMODWTTFYPHJVBEXUGUJLJTGZCNJLDILONKQRTYJEEUIGHMYNYREUQFOQSYTPZJDCBDMRALCCYHKKRI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