Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为何这样能过,这样过不了?WA的代码: #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int main() { unsigned int n; char a[30][30]; while(cin>>n) { if(n==0) break; int b[15]= {0},min=26,sum=0; for(int i=0; i<n; i++) { for(int j=0; j<25; j++) { cin>>a[i][j]; if(a[i][j]==' ') b[i]++; } getchar(); if(b[i]<=min) min=b[i]; } for(int i=0; i<n; i++) { b[i]-=min; sum+=b[i]; } cout<<sum<<endl; } } AC代码: #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int main() { unsigned int n; char a[30]; while(cin>>n) { if(n==0) break; getchar(); int b[15]= {0},min=26,sum=0; for(int i=0; i<n; i++) { gets(a); for(int j=0; j<25; j++) { if(a[j]==' ') b[i]++; } if(b[i]<=min) min=b[i]; } for(int i=0; i<n; i++) { b[i]-=min; sum+=b[i]; } cout<<sum<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator