修改文件结构。

This commit is contained in:
unlockable
2023-02-21 10:56:54 +08:00
parent a64cfdd9f3
commit 40182871f4
83 changed files with 0 additions and 0 deletions

44
POP/11/Exercise03.c Normal file
View File

@@ -0,0 +1,44 @@
#include <stdio.h>
#include <stdbool.h>
int findIndex(int a[], int num) {
int i = 0;
for (i = 0; i < 10; i++) {
if (a[i] == num) {
return i;
}
}
return -1;
}
int main() {
int a[10] = {0};
int *pa[10] = {0};
int *tmp;
int i = 0;
bool moved = true;
for(i = 0; i < 10; i++) {
pa[i] = a+i;
scanf("%d", a+i);
}
while(moved) {
moved = false;
for (i = 0; i < 9; i++) {
if (*pa[i] > *pa[i+1]) {
tmp = pa[i];
pa[i] = pa[i+1];
pa[i+1] = tmp;
moved = true;
}
}
}
for (i = 0; i < 10; i++) {
printf("%d ", *pa[i]);
}
printf("\n");
for (i = 0; i < 10; i++) {
printf("%d ", findIndex(a, *pa[i]));
}
printf("\n");
return 0;
}