提交记录 #512
提交时间:2024-12-17 13:58:57
语言:c
状态:Accepted
编译情况:编译成功
code.c: In function ‘main’:
code.c:18:4: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
18 | gets( sa );
| ^~~~
| fgets
code.c: In function ‘number’:
code.c:40:11: warning: implicit declaration of function ‘strtok’ [-Wimplicit-function-declaration]
40 | token=strtok(str," ");
| ^~~~~~
code.c:40:10: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
40 | token=strtok(str," ");
| ^
code.c:42:18: warning: implicit declaration of function ‘atoi’ [-Wimplicit-function-declaration]
42 | a[i].num=atoi(token);
| ^~~~
code.c:45:14: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
45 | token=strtok(NULL," ");
| ^
code.c:37:9: warning: variable ‘nums’ set but not used [-Wunused-but-set-variable]
37 | int nums[100];
| ^~~~
/usr/bin/ld: /tmp/ccAXkv3w.o: in function `main':
code.c:(.text.startup+0x1c): warning: the `gets' function is dangerous and should not be used.
固定测试点暂不可用
附加测试点暂不可用
5959-64,H26
int number(char*str,DATA a[])
{
int i=0,j=0,k=0;
char*token;
int nums[100];
int count=0;
token=strtok(str," ");
while(token!=NULL){
a[i].num=atoi(token);
nums[i]=a[i].num;
i++;
token=strtok(NULL," ");
}
count=i;
DATA sorted[100];
for (j=0;j<count;j++){
sorted[j]=a[j];
}
for (j=0;j<count-1;j++){
for(k=0;k<count-1-j;k++){
if (sorted[k].num>sorted[k+1].num){
DATA t=sorted[k];
sorted[k]=sorted[k+1];
sorted[k+1]=t;
}
}
}
for (j=0;j<count;j++){
for(k=0;k<count;k++){
if (sorted[j].num==a[k].num){
a[k].no=j+1;
break;
}
}
}
return count;
}