more tests

This commit is contained in:
Yaossg 2025-03-09 22:28:36 +08:00
parent d0f8b3e0ad
commit 1bcff515b7
22 changed files with 191 additions and 58 deletions

View file

@ -30,6 +30,7 @@ void queen(int x) {
if (x > 8) {
output();
a[0]++;
return;
}
for (int y = 1; y <= 8; ++y) {
if (ok(x, y)) {

36
demo/sort.c Normal file
View file

@ -0,0 +1,36 @@
int printf(char* format, ...);
int scanf(char* format, ...);
int exit(int status);
void swap(int* a, int* b) {
int t = *a;
*a = *b;
*b = t;
}
void sort(int a[], int n) {
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (a[i] > a[j]) {
swap(&a[i], &a[j]);
}
}
}
}
int a[100];
int n;
int main() {
printf("Enter the number of elements: ");
scanf("%d", &n);
printf("Enter %d integers: ", n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, n);
for (int i = 0; i < n; i++) {
printf("%d ", a[i]);
}
printf("\n");
}