| ||||||||||
| 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啊啊啊TAT#include <stdio.h>
#include <string.h>
long a[100001];
void op_qsort(long left, long right)
{
if(left >= right)
{
return ;
}
long i = left;
long j = right;
long key = a[left];
while(i < j)
{
while(i < j && key <= a[j])
{
j--;
}
a[i] = a[j];
while(i < j && key >= a[i])
{
i++;
}
a[j] = a[i];
}
a[i] = key;
op_qsort(left, i - 1);
op_qsort(i + 1, right);
}
void op_con(char str1[],long i)
{
long lenth, j, num;
lenth = strlen(str1);
for (j=0;j<=lenth-1;j++)
{
num=-1;
switch (str1[j])
{
case '0': {num=0;break;}
case '1': {num=1;break;}
case 'A': case 'B': case 'C': case '2': {num=2;break;}
case 'D': case 'E': case 'F': case '3': {num=3;break;}
case 'G': case 'H': case 'I': case '4': {num=4;break;}
case 'J': case 'K': case 'L': case '5': {num=5;break;}
case 'M': case 'N': case 'O': case '6': {num=6;break;}
case 'P': case 'R': case 'S': case '7': {num=7;break;}
case 'T': case 'U': case 'V': case '8': {num=8;break;}
case 'W': case 'X': case 'Y': case '9': {num=9;break;}
default: break;
}
if (num!=-1) a[i] = a[i]*10+num;
}
}
int main()
{
long i,n,ans,flag;
char str1[300];
scanf("%ld\n", &n);
for (i=0;i<=n-1;i++)
{
gets(str1);
op_con(str1,i);
}
op_qsort(0,n-1);
ans=1;
flag = 0;
for (i=0;i<=n-1;i++)
{
if (a[i]==a[i+1])
ans++;
else
{
if (ans!=1)
{
printf("%:03ld-%:04ld %ld\n",a[i]/10000,a[i]%10000, ans);
flag = 1;
}
ans=1;
}
}
if (flag==0) printf("No duplicates.");
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator