17
examples/fibonacci.c
Archivo normal
17
examples/fibonacci.c
Archivo normal
@@ -0,0 +1,17 @@
|
||||
// Example: Fibonacci calculation
|
||||
int printf(const char* format, ...);
|
||||
|
||||
int fibonacci(int n) {
|
||||
if (n <= 1) {
|
||||
return n;
|
||||
}
|
||||
return fibonacci(n - 1) + fibonacci(n - 2);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
for (i = 0; i < 10; i++) {
|
||||
printf("fib(%d) = %d\n", i, fibonacci(i));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
9
examples/hello.c
Archivo normal
9
examples/hello.c
Archivo normal
@@ -0,0 +1,9 @@
|
||||
// Example C programs for testing
|
||||
|
||||
// examples/hello.c
|
||||
int printf(const char* format, ...);
|
||||
|
||||
int main() {
|
||||
printf("Hello, World!\n");
|
||||
return 0;
|
||||
}
|
||||
37
examples/sorting.c
Archivo normal
37
examples/sorting.c
Archivo normal
@@ -0,0 +1,37 @@
|
||||
// Example: Array operations
|
||||
int printf(const char* format, ...);
|
||||
|
||||
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 arr[] = {64, 34, 25, 12, 22, 11, 90};
|
||||
int n = 7;
|
||||
int i;
|
||||
|
||||
printf("Original array: ");
|
||||
for (i = 0; i < n; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
bubble_sort(arr, n);
|
||||
|
||||
printf("Sorted array: ");
|
||||
for (i = 0; i < n; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Referencia en una nueva incidencia
Block a user