Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

输入和输出个数不一样,测试用例怎么写啊? #348

Closed
SuWeipeng opened this issue Jan 3, 2021 · 12 comments
Closed

输入和输出个数不一样,测试用例怎么写啊? #348

SuWeipeng opened this issue Jan 3, 2021 · 12 comments

Comments

@SuWeipeng
Copy link

附上例程

#include <stdio.h>
int main(){
  int n;
  int k;
  scanf("%d",&n);
  while(n--){
    int i = 2;
    scanf("%d",&k);
    while(i<=k){
      if(k%i==0){
        if(k!=i){
          printf("%d\r\n",0);
          break;
        }else{
          printf("%d\r\n",1);
        }
      }
      i++;
    } 
  }
}
@SuWeipeng
Copy link
Author

第一个数是循环次数,没有对应的输出。怎么办?

@virusdefender
Copy link
Contributor

没懂啥意思,没啥没输出

@SuWeipeng
Copy link
Author

没懂啥意思,没啥没输出

Snipaste_2021-01-03_18-08-00

@renbaoshuo
Copy link

这是题目的问题吧...

我觉得你来错地方了,应该去找那个OJ的管理员

@SuWeipeng
Copy link
Author

这是题目的问题吧...

我觉得你来错地方了,应该去找那个OJ的管理员

我是在自己写题目自己测试,还不太懂这个 OJ 的判定机制。不会写这个程序的测试用例。试了几次,怎么写都会判断成错的。

@SuWeipeng
Copy link
Author

就是输入的个数输出的个数不一样时,怎么写测试用例能判断是对的呢?

@SuWeipeng
Copy link
Author

我就是 OJ 的管理员,以前没弄过,刚开始了解。

@renbaoshuo
Copy link

我觉得您可以先了解一下如何出题。


这是正确的样例:

[input]
2
2
6

[output]
1
0

@SuWeipeng
Copy link
Author

我觉得您可以先了解一下如何出题。

这是正确的样例:

[input]
2
2
6

[output]
1
0

第一次我就是这么写的,结果是”Wrong Answer",附上我的用例。

000002.zip

@SuWeipeng
Copy link
Author

就是上面一开始的程序,写个能跑对的测试用例好难,我都试了 20 次了没有写对。

@renbaoshuo
Copy link

您的程序也有问题,在 Linux 环境下,换行符是 \n (LF) 而非 Windows 下的 \r\n (CRLF) 。

下面是修正后的程序:

#include <stdio.h>

int main() {
    int n;
    int k;
    scanf("%d", &n);
    while (n--) {
        int i = 2;
        scanf("%d", &k);
        while (i <= k) {
            if (k % i == 0) {
                if (k != i) {
                    printf("%d\n", 0);
                    break;
                } else {
                    printf("%d\n", 1);
                }
            }
            i++;
        }
    }
}

@SuWeipeng
Copy link
Author

您的程序也有问题,在 Linux 环境下,换行符是 \n (LF) 而非 Windows 下的 \r\n (CRLF) 。

下面是修正后的程序:

#include <stdio.h>

int main() {
    int n;
    int k;
    scanf("%d", &n);
    while (n--) {
        int i = 2;
        scanf("%d", &k);
        while (i <= k) {
            if (k % i == 0) {
                if (k != i) {
                    printf("%d\n", 0);
                    break;
                } else {
                    printf("%d\n", 1);
                }
            }
            i++;
        }
    }
}

啊!就是这个问题,对了!对了!终于对了!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants