qijingbo_ 2023-10-17 22:46 采纳率: 100%
浏览 14
已结题

刚来csdn社区大家看看我这段代码哪里错了

#求助大神解决问题,大一新生小白;

img

img


#我这样写为啥错了:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
  char vocabulary[1000];
  int shell[1000];
  scanf("%s", vocabulary);
  int i = 0;
  int len = strlen(vocabulary);
  for (i = 0; i < len; i++)
  {
    int d = vocabulary[i]; //对照Ascall码值 ; 
    if (d < 97)
    {
      d = d + 32;   //如果检测到大写字母则将数值加32转化为小写字母; 
    }
    shell[d]++;
  }
  int count; 
  int max = shell[97];
  int maxnumber = 97;
  for (count=98;count<= 122;count++)
  {
    if (shell[count] > max)
    {
      max = shell[count];
      maxnumber = count;
    }
    else{
        continue;
    }
  }
  printf("%c\n", maxnumber);
  printf("%d", max);
  return 0;
}

  • 写回答

2条回答 默认 最新

  • 柯本 2023-10-17 23:02
    关注

    程序至少有一个问题,你的shell没有初始化
    改shell[1000]={0};

    本回答被专家选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月29日
  • 专家已采纳回答 10月21日
  • 创建了问题 10月17日