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 |
坑爹啊,用G++超时,但用C++就AC了,附代码,求简化#include<iostream> #include<string.h> #include<stdio.h> #include<algorithm> using namespace std; char map(char c){ switch(c){ case'A': case'B': case'C': case '2': return '2';break; case'D': case'E': case'F': case '3': return '3';break; case'G': case'H': case'I': case '4': return '4';break; case'J': case'K': case'L': case '5': return '5';break; case'M': case'N': case'O': case '6': return '6';break; case'P': case'R': case'S': case '7': return '7';break; case'T': case'U': case'V': case '8': return '8';break; case'W': case'X': case'Y': case '9': return '9';break; case'1': return '1';break; case'0': return '0';break; default: return '#';break; } } int main(){ int n, m = 0, i, j=0, k, mark, tag = 0, text = 0; long a[100000]; char str[100]={1}, ch, num[7]; cin>>n; k=n; while(n--){ cin>>str; j = 0; for(i = 0; i < strlen(str);i++){ ch = map(str[i]); if(ch != '#'){ num[j]=ch; j++; } } sscanf(num, "%7d", (a+m)); m++; } sort(a, a+k); for(i = 0; i< k - 1; i++){ mark = 1; for(j = i+1; j < k; j++){ if(a[i] == a[j]) mark++; else break; } if(mark != 1){ printf("%03d-%04d %d\n",a[i]/10000,a[i]%10000,mark); tag = 1; } i = j - 1; } if(tag == 0) 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