Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
81192 何思佳 处理随机数 C++ Compile Error 0 MS 0 KB 588 2024-07-12 10:49:46

Tests(0/0):


Code:

#include<stdio.h> #define N 100 void main() { char c; int n,a[100],b[100],i,j,k = 0,flag = 1,t; scanf("%d",&c); for(i = 0; i < N; i++) scanf("%d",&a[i]); for(i = 0; i < N; i++) { flag = 1; for(j = 0; j < i; j++) if(a[i] == b[j]) flag = 0; if(flag) { b[k] = a[i]; k++; } } if(c=='A') { for(i = 0; i < k-1; i++) { n=i; for(j=i+1;j<k;j++) if(b[j]<b[n]) n=j; t=b[n];b[n]=b[i];b[i]=t; } } if(c=='D') { for(i = 0; i < k-1; i++) { n=i; for(j=i+1;j<k;j++) if(b[j]>b[n]) n=j; t=b[n];b[n]=b[i];b[i]=t; } } for(i = 0; i < k; i++) printf("%-4d",b[i]); }


Run Info:

Main.cc:3:11: error: '::main' must return 'int'
 void main()
           ^
Main.cc: In function 'int main()':
Main.cc:7:14: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'char*' [-Wformat=]
 scanf("%d",&c);
              ^
Main.cc:7:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d",&c);
               ^
Main.cc:9:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d",&a[i]);
                  ^