提交记录 #367
提交时间:2024-12-03 08:37:49
语言:c
状态:CompileError
编译情况:编译错误
code.c: In function ‘sort’:
code.c:20:11: error: parameter name omitted
20 | void sort(int*,int n,int flag){
| ^~~~
code.c:21:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘==’ token
21 | for(int i==0;i<n-1;i++){
| ^~
code.c:21:18: error: ‘i’ undeclared (first use in this function)
21 | for(int i==0;i<n-1;i++){
| ^
code.c:21:18: note: each undeclared identifier is reported only once for each function it appears in
code.c:21:23: error: expected ‘)’ before ‘;’ token
21 | for(int i==0;i<n-1;i++){
| ~ ^
| )
code.c:23:26: error: ‘arr’ undeclared (first use in this function)
23 | if((flag==0&&arr[j]>arr[j+1])||(flag==1;arr[j]<arr[j+1])){
| ^~~
code.c:23:52: error: expected ‘)’ before ‘;’ token
23 | if((flag==0&&arr[j]>arr[j+1])||(flag==1;arr[j]<arr[j+1])){
| ~ ^
| )
code.c: In function ‘output’:
code.c:39:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
39 | printf("%d,",&arr[i]);
| ~^ ~~~~~~~
| | |
| int int *
| %ls
固定测试点暂不可用
附加测试点暂不可用
49【小学】整数排序——指针
void sort(int*,int n,int flag){
for(int i==0;i<n-1;i++){
for (int j=0;j<n-i-1;j++){
if((flag==0&&arr[j]>arr[j+1])||(flag==1;arr[j]<arr[j+1])){
int t=arr[j];
arr[j]=arr[j+1];
arr[j+1]=t;
}
}
}
}
int input(int *arr,int n){
for (int i=0;i<n;i++){
scanf("%d",&arr[i]);
}
return 0;
}
int output(int *arr,int n){
for (int i=0;i<n;i++){
printf("%d,",&arr[i]);
}
printf("\n");
return 0;
}