社区讨论
c语言报错 求助
P1125[NOIP 2008 提高组] 笨小猴参与者 5已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @lowwki7n
- 此快照首次捕获于
- 2023/11/13 20:50 2 年前
- 此快照最后确认于
- 2023/11/13 22:21 2 年前
运行报错:process exited with return value 3221225620 搜了下是除0错误 我这里面没有除法呀
CPP#include<stdio.h>
#include<math.h>
#include<string.h>
int sushu(int n)
{
if(n==2) return 1;
if(n%2==0) return 0;
for (int i=0;i<sqrt(n);i++){
if (n%i==0) return 0;
}
return 1;
}
int main()
{
char s[101];
int cnt[200],max=0,min=100;
for (int i=0;i<200;i++){
cnt[i]=0;
}
scanf("%s",s);
for (int i=0;i<strlen(s)&&cnt[s[i]]!=0;i++){
cnt[s[i]]++;
if(cnt[s[i]]>max) max=cnt[s[i]];
if(cnt[s[i]]<min) min=cnt[s[i]];
}
int judge=max-min;
if(sushu(judge)){
printf("Lucky Word\n%d",judge);
}else{
printf("No Answer\n0");
}
return 0;
}
回复
共 6 条回复,欢迎继续交流。
正在加载回复...