kiem tien, kiem tien online, kiem tien truc tuyen, kiem tien tren mang
Thursday, October 2, 2014

viết chương trình c nhập vào 1 mảng bất kì và sắp xếp mảng theo thứ tự tăng dần rồi in ra màn hình mảng đã sắp xếp

#include<stdio.h>
#include<conio.h>
int a[100];
void main()
{
int i, j, n,k;
printf("nhap so phan tu cua mang: ");
scanf_s("%d", &n);
for (i = 0; i < n; i++)
{
printf("nhap phan tu thu %d: ", i + 1);
scanf_s("%d", &a[i]);
}
for (i = 0; i < n-1;i++)
for (j = i+1; j < n;j++)
if (a[i]>a[j])
{
k = a[i];
a[i] = a[j];
a[j] = k;
}
printf("mang sau khi da sap xep la:\n");
for (i = 0; i < n; i++) printf(" %d ", a[i]);
_getch();
}

02 Oct 2014

0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

domain, domain name, premium domain name for sales

Popular Posts