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 |
为什么这个代码结果是runtime error。。。???改动了很久了#include "iostream" #include "Cstring" #include "stdlib.h" using namespace std; #define MAX 200 char getin[MAX][60]; char sorted[MAX][60];//录入后数组 bool flag[MAX];//是否输出判断 int counter[MAX],putnumber[MAX];//重复次数计数数组 char output[MAX][60];//最终输出数组 char used[60];//临时中转数组 char choose(char s) { switch(s) { case 'A':case 'B':case 'C':return '2'; case 'D':case 'E':case 'F':return '3'; case 'G':case 'H':case 'I':return '4'; case 'J':case 'K':case 'L':return '5'; case 'M':case 'N':case 'O':return '6'; case 'P':case 'S':case 'R':return '7'; case 'T':case 'U':case 'V':return '8'; case 'W':case 'Y':case 'X':return '9'; default:return s; } } int main() { int T,i=0,sumup,can_out_put=0; cin>>T; sumup=T; int ishere; while (T--) { ishere=0; cin>>getin[i]; int length=strlen(getin[i]); for(int j=0;j<length;j++) { if (getin[i][j]!='-') getin[i][j]=choose(getin[i][j]); else NULL; } int k=0; for (int j=0;j<length;j++) { if (getin[i][j]!='-') { used[k]=getin[i][j]; k++; } } int usedlength=strlen(used); memcpy(getin[i],used,usedlength); getin[i][usedlength]='\0'; for (int j=length-1;j>2;j--) { getin[i][j+1]=getin[i][j]; } getin[i][3]='-'; for (int j=0;j<i+1;j++) { if(!strcmp(sorted[j],getin[i])) { ishere=1; counter[j]++; break; } } if(!ishere) { for (int j=0;j<T;j++) { if(counter[j]==0) { memcpy(sorted[j],getin[i],strlen(getin[i])); counter[j]++; break; } else continue; } } i++; } for (int j=0;j<sumup;j++) { if (counter[j]>1) { flag[j]=1; can_out_put++; } else NULL; } int p=0,t=0; for (int j=0;j<sumup;j++) { if (flag[j]) { strcpy(output[p],sorted[j]); putnumber[p]=counter[j]; p++; } else NULL; } for (p=0;p<can_out_put;p++) { for(int j=p+1;j<can_out_put;j++) { if (strcmp(output[p],output[j])>0) { strcpy(used,output[p]); strcpy(output[p],output[j]); strcpy(output[j],used); t=putnumber[p]; putnumber[p]=putnumber[j]; putnumber[j]=t; } else NULL; } } if(can_out_put==0) cout<<"No duplicates."<<endl; else { for (int j=0;j<can_out_put;j++) cout<<output[j]<<" "<<putnumber[j]<<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