Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
143350 王奕杰 19选班长II C++ Compile Error 0 MS 0 KB 721 2026-01-12 19:25:58

Tests(0/0):


Code:

#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 a[101]={0},A=0,B=0,C=0,x=0,Tot=0; while(1){ cin>>x; if(x==-1) break; a[x]++; tot++; } cout<<"A="<<a[1]<<endl; cout<<"B="<<a[2]<<endl; cout<<"C="<<a[3]<<endl; cout<<"Tot="<<Tot<<endl; if(a[1]>tot*1.0/2) cout<<"A-yes"; else if(a[2]>tot*1.0/2) cout<<"B-yes"; else if(a[3]>tot*1.0/2) cout<<"C-yes"; else cout<<"all-NO"; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:14:9: error: 'tot' was not declared in this scope
         tot++;
         ^
Main.cc:20:11: error: 'tot' was not declared in this scope
   if(a[1]>tot*1.0/2)
           ^
Main.cc:8:20: warning: unused variable 'A' [-Wunused-variable]
     int a[101]={0},A=0,B=0,C=0,x=0,Tot=0;
                    ^
Main.cc:8:24: warning: unused variable 'B' [-Wunused-variable]
     int a[101]={0},A=0,B=0,C=0,x=0,Tot=0;
                        ^
Main.cc:8:28: warning: unused variable 'C' [-Wunused-variable]
     int a[101]={0},A=0,B=0,C=0,x=0,Tot=0;
                            ^