31 lines
684 B
C
31 lines
684 B
C
int printf(const char format[], ...);
|
|
int scanf(const char format[], ...);
|
|
|
|
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]) {
|
|
int t = a[i];
|
|
a[i] = a[j];
|
|
a[j] = t;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int n;
|
|
int a[100];
|
|
printf("Enter the number of elements in the array: ");
|
|
scanf("%d", &n);
|
|
printf("Enter the elements of the array: ");
|
|
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");
|
|
return 0;
|
|
} |