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 |
Re:错在哪里呢In Reply To:错在哪里呢 Posted by:zgxzy at 2005-02-27 14:04:21 > 请高手指点 > > #include <iostream.h> > > void main() > { > char szLetters1[73]; > char szLetters2[73]; > char szLetters3[73]; > char szLetters4[73]; > cin.getline(szLetters1,73); > cin.getline(szLetters2,73); > cin.getline(szLetters3,73); > cin.getline(szLetters4,73); > > > > int nSta[26]; > for (int i=0;i<26;i++) > nSta[i]=0; > for (i=0;i<72;i++){ <---至少这里错了 > if (szLetters1[i]>='A'&&szLetters1[i]<='Z') > nSta[szLetters1[i]-'A']++; > if (szLetters2[i]>='A'&&szLetters2[i]<='Z') > nSta[szLetters2[i]-'A']++; > if (szLetters3[i]>='A'&&szLetters3[i]<='Z') > nSta[szLetters3[i]-'A']++; > if (szLetters4[i]>='A'&&szLetters4[i]<='Z') > nSta[szLetters4[i]-'A']++; > } > > int cMaxLetter=0; > for (i=0;i<26;i++){ > if (nSta[i]>nSta[cMaxLetter]) > cMaxLetter=i; > } > int nCurrentFrequency=nSta[cMaxLetter]; > for (;nCurrentFrequency>0;nCurrentFrequency--){ > for (i=0;i<26;i++){ > if (nSta[i]==nCurrentFrequency){ > cout <<"* "; > nSta[i]-=1; > } > else > cout <<" "; > > } > cout <<endl; > } > for (int k=0;k<26;k++) > cout <<char(k+'A')<<" "; > > > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator