Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
102446 | 欧阳俊懿 | 19选班长II | C++ | Compile Error | 0 MS | 0 KB | 869 | 2024-12-21 16:28:24 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int i=0,j=0,n=0,A=0,B=0,C=0; int arr[10001]={0}; while(1) { cin >> arr[i]; if(arr[i]==-1) break; i++; n++; } for(i=0;i<n;i++) { if(arr[i]==1) A++; } else if(arr[i]==2) { B++; } else if(arr[i]==3) { C++; } cout<<"A="<<A<<endl; cout<<"B="<<A<<endl; cout<<"C="<<A<<endl; cout<<"Tot="<<n<<endl; if(A>n/2) { cout<<"A-yes"<<endl; else if(B>n/2) cout<<"B-yes"<<endl; else if(C>n/2) cout<<"C-yes"<<endl; else cout<<"all-NO"<<endl; } return 0; }
Main.cc: In function 'int main()': Main.cc:23:5: error: 'else' without a previous 'if' else if(arr[i]==2) ^ Main.cc:38:1: error: expected '}' before 'else' else if(B>n/2) ^ Main.cc:8:13: warning: unused variable 'j' [-Wunused-variable] int i=0,j=0,n=0,A=0,B=0,C=0; ^ Main.cc: At global scope: Main.cc:45:5: error: expected unqualified-id before 'return' return 0; ^ Main.cc:46:1: error: expected declaration before '}' token } ^