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 |
麻烦高人看一下,代码老是提示wrong answer#include <iostream> #define NUM 100000 using namespace std; char output[NUM][20]={'Q'}; int main() { int num=1; char input[20]={"RE34JI8"}; int i=0;//input数组下标 int j=0;//output数组 行 int k=0;//output数组 列 cin>>num; while(num>0)// { cin>>input; i=0; k=0;//从0开始 while(input[i]!='\0') { if(k==3)//添加连字符 { output[j][k]='-'; k++; } if ('0'<=input[i] && input[i]<='9')//是数字 { output[j][k]=input[i]; i++; k++; } else//是字母 { if ('A'<= input[i] && input[i]<='Z') { switch (input[i]) { case 'A': case 'B': case 'C': output[j][k]='2'; break; case 'D': case 'E': case 'F': output[j][k]='3'; break; case 'G': case 'H': case 'I': output[j][k]='4'; break; case 'J': case 'K': case 'L': output[j][k]='5'; break; case 'M': case 'N': case 'O': output[j][k]='6'; break; case 'P': case 'R': case 'S': output[j][k]='7'; break; case 'T': case 'U': case 'V': output[j][k]='8'; break; case 'W': case 'X': case 'Y': output[j][k]='9'; break; default: break; }//switch k++; i++; } else { i++; } }//if('0'<=input[i] && input[i]<='9') } //cout<<output[j]; j++; num--; }// 最外成while循环 int count; int z=0; int x; int y;//计算相同的个数并且输出 while(output[z][0]!='\0' && z<NUM) { x=z+1; count=1; while(output[x][0]!='\0' && output[x][0]!='Z' && x<NUM) { for (y=0;y<8;y++) { if (output[z][y]==output[x][y] && output[x][y]!='Z') { } else { break; } } if(y==8) { count++; output[x][0]='Z'; } x++; } if (output[z][0]!='Z') { cout<<output[z]<<" "<<count<<endl; } z++; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator