要是在平时,这种题目我分分钟写出来,但是最近几天很累,唉,急!
拜托了,明早起来只好自己写了
那你就自己完成吧,不会就不会。题目确实简单,你要是有实力,提问这点时间自己都写完了
2.
#include<stdio.h>
char c[100000];
void funtion(char c[])
{
int y=0,s=0,q=0,t=0,i=0;
while(c[i]!='\0')
{
if((c[i]>='a'&&c[i]<='z')||(c[i]>='A'&&c[i]<='Z'))
{
y++;
}
else if(c[i]<='9'&&c[i]>='0')
{
t++;
}
else if(c[i]==' ')
{
s++;
}
else
{
q++;
}
i++;
}
printf("%d %d %d %d",y,t,s,q);
}
int main()
{
gets(c);//用来接受从键盘输入的一个字符串(可带空格)
funtion(c);
return 0;
}
我就哈哈哈哈
//第二题:统计字符类别个数
#include<stdio.h>
int main()
{
char c;
int letters_num = 0, space_num = 0, digit_num = 0, other_num = 0;
while ((c = getchar()) != '\n')//输入换行符退出循环
{
if ((c >= 'a'&&c <= 'z') || (c >= 'A'&&c <= 'Z')) letters_num++;
else if (c == ' ') space_num++;
else if (c >= '0'&&c <= '9') digit_num++;
else other_num++;
}
printf("%d %d %d %d", letters_num, space_num, digit_num, other_num);
return 0;
}
题主估计写好了