注册 登录
编程论坛 C++教室

运行一个程序出了点错误 求改改

艾克 发布于 2013-11-21 15:10, 574 次点击
#include<stdio.h>
int main()
{int i,j,upp,low,dig,spa,oth;
char text[3][80];
upp=low=dig=spa=oth=0;
for (i=0;i<3;i++)
{printf("piease input line %d:\n",i+1);
gets(text[i]);
for (j=0;j<80 && text[i][j]!='\0';j++)
{if (text[i][j]>='A' && text[i][j]<='Z')
upp++;
else if (text[i][j]>='a' && text[i][j]<='z')
low++;
else if (text[i][j]>='0' && text[i][j]<='9')
dig++;
 else if (text[i][j]=='')
 spa++;
else
 oth++;
}
}
printf("\nupper case:%d\n",upp);
printf("lower case %d\n",low);
printf("digit   :%d\n",dig);
printf("space   :%d\n",spa);
printf("other   :%d\n",oth);
return 0;
}
8 回复
#2
艾克2013-11-21 15:12
那里错了   说明一下
#3
rjsp2013-11-21 15:45
原来是同一个人,你在自言自语呀。

哪里错了 说明一下
若是编译错误,贴出编译器给出的错误信息
若是运行结果不符合你的预期,贴出你输入的信息、实际输出的信息 和 你期待的输出信息。
#4
peach54602013-11-21 15:45
以下是引用rjsp在2013-11-21 15:45:07的发言:

原来是同一个人,你在自言自语呀。

哪里错了 说明一下
若是编译错误,贴出编译器给出的错误信息
若是运行结果不符合你的预期,贴出你输入的信息、实际输出的信息 和 你期待的输出信息。

+1
#5
a1902054602013-11-21 19:17
else if (text[i][j]=='')
这一条错啦
#6
wu27826418032013-11-21 21:44
else if (text[i][j]=='')
这一条错啦
单引号中间没有空格

#7
thb2013-11-21 22:30
else if (text[i][j]=='')处,''内加一个空格
#8
bigstupidboy2013-11-23 17:36
#include<stdio.h>
int main()
{int i,j,upp,low,dig,spa,oth;
char text[3][80];
upp=low=dig=spa=oth=0;
for (i=0;i<3;i++)
{printf("piease input line %d:\n",i+1);
gets(text[i][j]);
for (j=0;j<80 && text[i][j]!='\0';j++)
{if (text[i][j]>='A' && text[i][j]<='Z')
upp++;
else if (text[i][j]>='a' && text[i][j]<='z')
low++;
else if (text[i][j]>='0' && text[i][j]<='9')
dig++;
else if (text[i][j]=='')
spa++;
else
oth++;
}
}
printf("\nupper case:%d\n",upp);
printf("lower case %d\n",low);
printf("digit   :%d\n",dig);
printf("space   :%d\n",spa);
printf("other   :%d\n",oth);
return 0;
}
#9
影随风2013-11-23 18:21
else if (text[i][j]=='')

单引号中间敲进一个空格就对了。
1