搜索
首页 电脑/网络 软件

C语言问题

  有一篇文章,共有3行文字,每行有80个字符。要求分别统计出其中英文大写字母、小写字母、数字、空格以及其他字符的个数。
  这么编怎么错了????高手帮帮忙啊,解决了我会再加分的 main() { int count1=0,count2=0,count3=0,i,j,k; char str[3][80]; gets(str); for(i=0;i='0') count1++; else if(str[i][j]>='a'&&str[i][j]='A'&&str[i][j]<='Z') count2++; else count3++; } printf("the count of the number=%d\n",count1); printf("the count of the ABC=%d\n",count2); printf("the count of the other string=%d\n",count3); } 。

全部回答

2007-03-24

0 0
    #include "stdio。
    h" #include #include #include void main() { int i,j,c,upper,lower,digit,space,punch; char str[3][80]; upper=lower=digit=space=punch=0; for(i=0;i<3;i++) { gets(str[i]); for(j=0;j<10;j++) { c=str[i][j]; if(isupper(c)!=0) { upper++; } if(islower(c)!=0) { lower++; } if(isdigit(c)!=0) { digit++; } if(isspace(c)!=0) { space++; } if(ispunct(c)!=0) { punch++; } } } printf(" upper%d\n lower%d\n digit%d\n space%d\n punch%d\n",upper,lower,digit,space,punch); } 调过了,符合你的要求。

2007-03-24

344 0
这里是二维数组,所以输入的时候,应该这么写:gets(*str)

2007-03-24

377 0
    前面补上k=0 if(str[i][j]='0') count1++; else if(str[i][j]>='a'&&str[i][j]='A'&&str[i][j]<='Z') count3++; else k++; printf("the count of the number=%d\n",count1); printf("the count of the ABC=%d\n",count2); printf("the count of the other string=%d\n",count3); printf("the count of the other teshuzifu=%d\n",k); 。
    。

类似问题换一批

热点推荐

热度TOP

相关推荐
加载中...

热点搜索 换一换

电脑/网络
软件
硬件
电脑装机
程序设计
互联网
操作系统/系统故障
笔记本电脑
反病毒
百度
软件
软件
多媒体软件
系统软件
办公软件
网络软件
图像处理软件
举报
举报原因(必选):
取消确定举报