题干:
我的代码:
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cstring>
#include<algorithm>
using namespace std;
struct bign{
int length;
int d[1001];
bign(){
memset(d,0,sizeof(d));
length=0;
}
}N[101];
bool cmp(struct bign a,struct bign b){
if(a.length>b.length){
return 0;
}else if(a.length<b.length){
return 1;
}else{
int i;
for(i=a.length-1;i>=0;i--){
if(a.d[i]<b.d[i]){
return 1;
}else if(a.d[i]>b.d[i]){
return 0;
}
}
}
}
int main(){
int n;
int j;
while(scanf("%d",&n)!=EOF){
int i;
for(i=0;i<n;i++){
char c[1002];
scanf("%s",c);
for(j=strlen(c)-1;j>=0;j--){
N[i].d[j]=c[strlen(c)-j-1]-'0';
N[i].length++;
}
}
sort(N,N+n,cmp);
for(j=0;j<n;j++){
for(i=N[j].length-1;i>=0;i--){
printf("%d",N[j].d[i]);
}
printf("\n");
}
}
return 0;
}
OJ网站给我的报错是
请问我的代码错在哪里?