| ||||||||||
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 <fstream> using namespace std; void main(){ // ifstream cin("data.txt"); while(1){ int n,i,j,k; cin>>n; if(n==0)break; char str[2100][10]; for(i=0;i<n;i++){ cin>>str[i]; } int len=strlen(str[0]); char tmp[10]; for(i=0;i<7;i++){ int a[26]; memset(a,0,sizeof(a)); int maxc; char c; for(j=0;j<n;j++){ a[str[j][i]-'a']++; } int max=-1; int chac; for(j=0;j<26;j++){ if(a[j]>max){ max=a[j]; chac=j; } } tmp[i]=chac+'a'; } tmp[7]='\0'; int dis=0; for(i=0;i<n;i++){ for(j=0;j<7;j++){ if(str[i][j]!=tmp[j])dis++; } } cout<<"The highest possible quality is 1/"<<dis<<"."<<endl; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator