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 |
哪位高手帮我看看程序啊 缺少快排 我不会用qsort() 谁帮我把qsort()加进去啊#include"iostream" #include<stdlib.h> using namespace std; struct S { long x; int y; }s[100001]; void Input(int & d) { int i=1; d=0;char c; while(i!=0) { scanf("\n%c",&c); if(c!='-') { if(c=='A'||c=='B'||c=='C')c=50; if(c=='D'||c=='E'||c=='F')c=51; if(c=='G'||c=='H'||c=='I')c=52; if(c=='J'||c=='K'||c=='L')c=53; if(c=='M'||c=='N'||c=='O')c=54; if(c=='P'||c=='R'||c=='S')c=55; if(c=='T'||c=='U'||c=='V')c=56; if(c=='W'||c=='X'||c=='Y')c=57; d=10*d+c-48; i=(i+1)%8; } } } int main() { int i,j,flag; for(i=0;i<100001;i++) { s[i].x=-1; s[i].y=0; } int n; cin>>n; int d,k=0; for( j=1;j<=n;j++) { Input(d); flag=1; for( i=0;i<=k;i++) if(s[i].x==d) { s[i].y++;flag=0;break; } if(flag) { s[k].x=d;s[k].y++;k++; } } flag=1; for(i=0;i<n;i++) if(s[i].y!=0&&s[i].y!=1) { flag=0; printf("%03ld-%04ld %d\n", s[i].x/10000, s[i].x%10000, s[i].y); } if(flag) 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