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 |
为什么这个程序怎么看都是对的呢请高手指导! 算法很一般,没什么出格的地方啊 #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