提交记录 #409
提交时间:2024-12-03 18:20:55
语言:c
状态:CompileError
编译情况:编译错误
code.c:49:5: error: redefinition of ‘main’
49 | int main() {
| ^~~~
code.c:8:5: note: previous definition of ‘main’ was here
8 | int main()
| ^~~~
固定测试点暂不可用
附加测试点暂不可用
53【小学】比较大小——指针
#include <stdio.h>
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
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;
}
int main() {
int n;
scanf("%d", &n);
int a[100], b[100];
input(a, 2 * n);
input(b, 2 * n);
for (int i = 0; i < 2 * n; i++) {
if (a[i] > b[i]) {
swap(&a[i], &b[i]);
}
}
output(a, 2 * n);
output(b, 2 * n);
return 0;
}