提交记录 #370
提交时间:2024-12-03 09:20:08
语言:c
状态:CompileError
编译情况:编译错误
code.c: In function ‘sort’:
code.c:28:16: error: too few arguments to function ‘pf’
28 | if(pf(p[j]),p[j+1]>0){
| ^~
code.c:28:24: warning: left-hand operand of comma expression has no effect [-Wunused-value]
28 | if(pf(p[j]),p[j+1]>0){
| ^
code.c: In function ‘input’:
code.c:38:9: warning: implicit declaration of function ‘scaf’; did you mean ‘scanf’? [-Wimplicit-function-declaration]
38 | scaf("%d",&p[i]);
| ^~~~
| scanf
code.c: At top level:
code.c:50:12: error: parameter ‘a’ has just a forward declaration
50 | int up(int a;int b){
| ~~~~^
code.c:50:5: error: conflicting types for ‘up’
50 | int up(int a;int b){
| ^~
code.c:7:5: note: previous declaration of ‘up’ was here
7 | int up(int, int); // a<b:1; a=b:0;a>b:-1反序
| ^~
code.c: In function ‘up’:
code.c:51:8: error: ‘a’ undeclared (first use in this function)
51 | if(a<b)return 1;
| ^
code.c:51:8: note: each undeclared identifier is reported only once for each function it appears in
固定测试点暂不可用
附加测试点暂不可用
50【小学】整数再排序——指针
#include<stdio.h>
void sort(int *p,int n,int (*pf)(int,int)){
for (int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
if(pf(p[j]),p[j+1]>0){
int t=p[j];
p[j]=p[j+1];
p[j+1]=t;
}
}
}
}
int input(int *p,int n){
for (int i=0;i<n;i++){
scaf("%d",&p[i]);
}
return 0;
}
int output(int*p,int n){
for(int i=0;i<n;i++){
printf("%d",p[i]);
}
printf("\n");
return 0;
}
int up(int a;int b){
if(a<b)return 1;
if(a>b)return -1;
return 0;
}
int down(int a,int b){
if(a<b)return -1;
if(a>b)return 1;
return 0;
}