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 |
大佬们帮忙看一下为什么编译错误,我在我的编译器上编译没问题#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #define swap(a,b){a=a+b;b=a-b;a=a-b;} int CheckAndReturnNum(char *s); int main(void) { int n,i,j,q,count=0; scanf("%d", &n); int *data = (int *)malloc(n*sizeof(int)); char s[30]; for (i = 0; i <n; i++) { scanf("%s",s); data[i]=CheckAndReturnNum(s); } //printf("%03d-%04d %d\n", data[i] / 10000, data[i] % 10000); for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (data[i] < data[j]) swap(data[i], data[j]); } } for ( i = 0; i < n; i++) { count = 1; while (data[i]==data[i+1]) { i++; count++; } if (count > 1) printf("%03d-%04d %d\n", data[i] / 10000, data[i] % 10000, count); } free(data); return 0; } int CheckAndReturnNum(char *s) { int i, sum = 0,m=0; for (i = strlen(s) - 1; i >= 0; i--) { if (s[i] >= '0'&&*(s + i) <= '9' || *(s + i) >= 'A'&&*(s + i) <= 'Z') { if (s[i] >= '0'&&*(s + i) <= '9') { sum += (s[i] - '0') * pow(10, m); } if (*(s + i) >= 'A'&&*(s + i) <= 'Z') { if (s[i] > 'Q'&&s[i] < 'Z') sum += ((s[i] - 'Q') / 3 + 2)*pow(10,m); else sum += ((s[i] - 'A') / 3 + 2)*pow(10,m); } m++; } } return sum; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator