学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
发新话题
打印

哪儿错了

哪儿错了

统计个类型的字符个数
#include<stdio.h>
#include<ctype.h>
void main()
{
char str[3][80];
int i,j,a=0,b=0,c=0,d=0,e=0;
for(i=0;i<3;i++)
gets(str[i]);
for(i=0,j=0;i<3;i++)
{
if(isdigit(str[i][j])==1) a++;
if(islower(str[i][j])==1) b++;
if(isupper(str[i][j])==1) c++;
if(ispunct(str[i][j])==1) d++;
if(str[i][j]==' ')  e++;
if(j<80)
j++;}
printf("ying wen da xie zi mu ge shu wei %d.\n",c);
printf("xiao xie zi mu ge shu wei %d.\n",b);
printf("shu zi ge shu wei %d.\n",a);
printf("kong ge ge shu wei %d.\n",e);
printf("qi ta zi fu ge shu wei%d.\n",d);
}

TOP

第二个for循环并不能历遍所有输入字符
GIS
Geographic Information System
你在哪里?——》你的坐标?

TOP

2维 循环 不是这样弄的哦.你这样只到 str[2][2]

TOP

还是不行

#include<stdio.h>
#include<ctype.h>
#include<string.h>
void main()
{
char str[3][80];
int i,j,a=0,b=0,c=0,d=0,e=0;
for(i=0;i<3;i++)
gets(str[i]);
for(i=0;i<3;i++)
for(j=0;j<80;j++)
{
if(isdigit(str[i][j])) a++;
if(islower(str[i][j])) b++;
if(isupper(str[i][j])) c++;
if(ispunct(str[i][j])) d++;
if(str[i][j]==' ')  e++;
}
printf("ying wen da xie zi mu ge shu wei %d.\n",c);
printf("xiao xie zi mu ge shu wei %d.\n",b);
printf("shu zi ge shu wei %d.\n",a);
printf("kong ge ge shu wei %d.\n",e);
printf("qi ta zi fu ge shu wei %d.\n",d);
}

TOP

明白了

在输入是出了问题,程序对了

TOP

发新话题