问题 1行文字 80个字符 用一维数组 计算大小写字母,字符串长度等

来源:百度知道 编辑:UC知道 时间:2024/06/02 22:31:58
快 !

#include<stdio.h>
#include<string.h>
main()
{
int i,j,len;
char s[80];
printf("please input a string which has 80 chars :");
memset(s, 0, 80);
gets(s);
len = strlen(s);
i=j=0;
while(*s!='\0')
{
if(*s>'A'&&*s<'Z')i++;
if(*s>'a'&&*s<'z')j++;
s++;
}
printf("the big alphabet: [%d] the small alphabet: [%d] the string's length: [%d]\n",i,j,len);
}

nuzhidao