-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab7b1.c
More file actions
37 lines (32 loc) · 716 Bytes
/
lab7b1.c
File metadata and controls
37 lines (32 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<stdio.h>
int main()
{
int n ;
printf("Nhap mot so nguyen n: ");
scanf("%d", &n);
int a[n];
printf("Nhap du lieu cho mang %d phan tu: \n",n);
for(int i =0; i<n; i++)
{
printf("Nhap phan tu thu %d: ", i );
scanf("%d", &a[i]);
}
for(int i = 0; i < n-1; i++)
{
for(int j = i+1; j < n; j++)
{
if(a[i] > a[j])
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
printf("Mang da duoc sap xep theo chieu tang dan la: ");
for(int i =0; i <n; i++)
{
printf("%d ", a[i]);
}
return 0;
}