这个题目怕是有毒吧?

P1125 [NOIP2008 提高组] 笨小猴

@[908671152czy](/space/show?uid=76682) 还有,题目说的是如果它是质数,就输出那个数,否则就输出0不是吗,beijing结果是1,1不是质数难道不应该输出0吗
by B_Qu1e7 @ 2017-12-13 17:47:49


@[908671152czy](/space/show?uid=76682) 还有,你怕是傻了,为什么要加system("pause")啊,那不是调试才用的吗,
by B_Qu1e7 @ 2017-12-13 17:49:22


@[2016c01](/space/show?uid=5880) 改完以后依旧gg,全WA ```cpp #include<stdio.h> #include<math.h> int judgeprime(int n); int main() { char c; int a[26] = { 0 }, maxn, minn, cnt = 0, d = 0, i; maxn = a[0]; minn = 1; c = getchar(); while (c != '\n') { if (c > 'a'&&c < 'z') d = c - 96; a[d]++; c = getchar(); } for (i = 1; i < 26; i++) { if (a[i] > maxn) maxn = a[i]; else if (a[i] < minn&&a[i] != 0) minn = a[i]; } if (judgeprime(maxn - minn)) printf("Lucky Word\n%d", maxn - minn); else printf("No Answer\n0"); system("pause"); return 0; } int judgeprime(int n) { int cnt = 2, prime = 1; for (cnt = 2; cnt < fabs(n); cnt++) { if (n%cnt != 0) prime = 0; } if (n == 0 || n == 1) prime = 0; return prime; } ```
by 908671152czy @ 2017-12-13 17:49:59


@[908671152czy](/space/show?uid=76682) 你不知道如果用system("pause")会输出“请按任意键继续...”吗,难怪会错
by B_Qu1e7 @ 2017-12-13 17:50:23


@[908671152czy](/space/show?uid=76682) 根本就是system("pause")的错,那是调试才用的
by B_Qu1e7 @ 2017-12-13 17:51:11


@[2016c01](/space/show?uid=5880) 我用的是VS2017,如果不加system(“pause”),看不到结果,会闪退的。我试试,我把那个去掉再交。原先都是用codeblock,今天改用了VS2017.
by 908671152czy @ 2017-12-13 17:53:04


@[908671152czy](/space/show?uid=76682) 额你没有用C++吗
by B_Qu1e7 @ 2017-12-13 17:53:33


写C可以用C++5.11编译@[908671152czy](/space/show?uid=76682)
by B_Qu1e7 @ 2017-12-13 17:54:30


@[908671152czy](/space/show?uid=76682) 还有,你函数怕是用错了,fabs是求浮点数的绝对值,又没有浮点数,用fabs干嘛,这里应该是sqrt,开方吧
by B_Qu1e7 @ 2017-12-13 17:56:07


@[2016c01](/space/show?uid=5880) 好像是。。。。萌新记混了。。至于编译器我也不是了解很多,大一新生很懵逼啊
by 908671152czy @ 2017-12-13 17:58:17


上一页 | 下一页