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 <string> using namespace std; char strget[100]; char strstore[100001][8]; char array[8]; char b[26]={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6', '7','0','7','7','8','8','8','9','9','9','0'}; void print(char strstore[100001][8],int s,int k) { if(k!=0){ int count=0,l=0,cn=0,u; for(int i=0,j=0;i<s;i++){ count=1; while(strcmp(strstore[i],strstore[i+1])==0){count++;i++;} if(count>1){for(u=0;u<3;u++)cout<<strstore[i-1][u]; cout<<"-";for(u=3;u<7;u++)cout<<strstore[i-1][u]; cout<<" "<<count<<endl;cn++; } } if(cn==0)cout<<"No duplicates."<<endl; } } int compare(const void *arg1,const void*arg2 ) { return strcmp((char*) arg1, (char*) arg2); } int main() { int j,k,n=0,s=1; cin>>k; while(n<k){ cin>>strget; j=0; for(int i=0;strget[i]!='\0';i++){ if(strget[i]=='-')continue; else{ if( strget[i]=='0'||strget[i]=='1'||strget[i]=='2'||strget[i]=='3'||strget[i]=='4'||strget[i]=='5' ||strget[i]=='6'||strget[i]=='7'||strget[i]=='8'||strget[i]=='9') array[j]=strget[i]; else array[j]=b[(int)(strget[i]-'A')]; j++; } } array[7]='\0'; strcpy(strstore[s],array); s++;n++; } qsort(strstore,s,sizeof(strstore[0]),compare); print(strstore,s,k); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator