| ||||||||||
| 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 | |||||||||
itoa!! Compile Error?????有兴趣的大牛帮忙看看,解释一下itoa为什么会Compile Error.
#include "stdio.h"
#include "ctype.h"
#include "string.h"
#include "stdlib.h"
char num[10000000], tmp[10000], map[256];
int index[100000];
int cmp(const void *a, const void *b)
{
return *(int *)a > *(int *)b;
}
int main()
{
int n, result, ind = 0, i, j;
map['0'] = 0;
map['1'] = 1;
map['A'] = map['B'] = map['C'] = map['2'] = 2;
map['D'] = map['E'] = map['F'] = map['3'] = 3;
map['G'] = map['H'] = map['I'] = map['4'] = 4;
map['J'] = map['K'] = map['L'] = map['5'] = 5;
map['M'] = map['N'] = map['O'] = map['6'] = 6;
map['P'] = map['R'] = map['S'] = map['7'] = 7;
map['T'] = map['U'] = map['V'] = map['8'] = 8;
map['W'] = map['X'] = map['Y'] = map['9'] = 9;
memset(num, 0, sizeof(num));
scanf("%d", &n);
while(n--)
{
scanf("%s", tmp);
result = 0;
for(i = 0; i < (int) strlen(tmp); i++) {
if(isalpha(tmp[i]) || isdigit(tmp[i])) {
result = result * 10 + map[tmp[i]];
}
}
num[result]++;
if(num[result] == 2)
index[ind++] = result;
}
qsort(index, ind, sizeof(int), cmp);
for(i = 0; i < ind; i++) {
itoa(index[i], tmp, 10); // 就这里用了itoa
for(j = 0; j < 7; j++) {
if(j == 3)
printf("-%c", tmp[j]);
else
printf("%c", tmp[j]);
}
printf(" %d\n", num[index[i]]);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator