为了账号安全,请及时绑定邮箱和手机立即绑定

代码为何运行不正确

代码为何运行不正确

C
慕斯卡7229790 2018-12-06 16:57:55
#include<stdio.h>#include<string.h>int main(){ char a[40]; int i, j = 0, m = 0, n = 0, b = 0,t=0; scanf("%s", a); t=strlen(a); for (i = 0; i <t ; i++) {  if (a[i] >= '0'&&a[i] <= '9')   j += 1;   else if (a[i] >= 65 && a[i] <= 90 || a[i] >= 97 && a[i] <= 122)   m += 1;   else if (a[i] ==32) n += 1;  else b += 1; } printf("zimu=%d\n", m); printf("shuzi=%d\n", j); printf("kongge=%d\n", n); printf("qita=%d\n", b);}问题:统计字符串中字母、数字、空格和其他字符的个数。运行后各个统计的结果都不正确
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 558 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信