test commit with vscode

This commit is contained in:
juan 2021-12-01 21:05:19 +08:00
parent 92c01818fd
commit ceb39acadb
No known key found for this signature in database
GPG key ID: 5C1E5093C74F1DC7

38
pset10/sort.c Normal file
View file

@ -0,0 +1,38 @@
#include <stdio.h>
void bubbleSort(int a[], int n);
//输出数组中所有元素
void outputData(int data[], int elementCount);
int main() {
int n, i, num[10010];
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &num[i]);
bubbleSort(num, n);
outputData(num, n);
return 0;
}
/* 请在这里填写答案 */
void bubbleSort(int a[], int n) {
int tmp;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1; j++) {
if (a[j] > a[j + 1]) {
tmp = a[j];
a[j] = a[j + 1];
a[j + 1] = tmp;
}
}
}
}
void outputData(int data[], int elementCount) {
for (int i = 0; i < elementCount - 1; i++) {
printf("%d ", data[i]);
}
printf("%d\n", data[elementCount - 1]);
}