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<iomanip> using namespace std; int main() { int allNum; cin>>allNum; int result[100000][2]; for (int i = 0; i < 100000; i++) { result[i][0]=-1; result[i][1]=-1; } char inputNum[200]; int countNum,tempNum,bitNum = 0; int tempallNum = allNum; while(tempallNum) { cin>>inputNum; countNum = 0; tempNum = 0; bitNum = 0; for (int i = 0; i < 15; i++) { if (inputNum[i] >= 'Q') { inputNum[i] -= 1; } if (inputNum[i] >= 'Z') { inputNum[i] -= 1; } if (inputNum[i] >= 'A') { inputNum[i] = (inputNum[i] - 'A')/3 + '2'; } if (inputNum[i] >= '0' && inputNum[i] <= '9') { tempNum = inputNum[i] - '0'; countNum = tempNum + countNum*10; bitNum++; } if (bitNum == 7) { break; } } int i =0; while(result[i][0] != -1) { if (countNum == result[i][0]) { result[i][1]++; break; } i++; } if (result[i][0] == -1) { result[i][0] = countNum; result[i][1] = 1; } tempallNum--; } int i = 0; while(result[i][0] != -1) { i++; } i--; for (int k = 0;k < i; k++) { for (int j = i; j > k ;j--) { if (result[j][0] < result[j-1][0]) { tempNum = result[j][0]; result[j][0] = result[j-1][0]; result[j-1][0] = tempNum; tempNum = result[j][1]; result[j][1] = result[j-1][1]; result[j-1][1] = tempNum; } } } i = 0; bool p = false; while(result[i][0] != -1) { if (result[i][1] > 1) { cout<<setfill('0')<<setw(3)<<result[i][0]/10000<<"-"<<setfill('0')<<setw(4)<<result[i][0]%10000<<" "<<result[i][1]<<endl; p = true; } i++; } if (allNum == 1 || p == false) { cout<<"No duplicates."<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator