You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cbmc/specgen/web_interface/test_sample.c

39 lines
854 B

#include <stdio.h>
#include <stdlib.h>
// 一个简单的排序程序,用于测试文件上传功能
void bubble_sort(int arr[], int n) {
int i, j, temp;
for (i = 0; i < n-1; i++) {
for (j = 0; j < n-i-1; j++) {
if (arr[j] > arr[j+1]) {
// 交换元素
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
}
int main() {
int numbers[] = {64, 34, 25, 12, 22, 11, 90};
int n = sizeof(numbers) / sizeof(numbers[0]);
int i;
printf("排序前的数组: ");
for (i = 0; i < n; i++) {
printf("%d ", numbers[i]);
}
printf("\n");
bubble_sort(numbers, n);
printf("排序后的数组: ");
for (i = 0; i < n; i++) {
printf("%d ", numbers[i]);
}
printf("\n");
return 0;
}