SlideShare a Scribd company logo
1 of 2
#include<stdio.h>
#include<conio.h>
void nm(int a[],int n)
{
for(int i=0;i<n;i++)
{
printf("a[%d]: ",i+1);
scanf("%d",&a[i]);
}
}
void xm(int a[],int n)
{
for(int i=0;i<n;i++)
{
printf(" %d ",a[i]);
}
}
//doi cho truc tiep
void sapxep(int a[],int n)
{
int t;
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i] ;
a[i]=a[j];
a[j]=t;
}
}
for(int m=0;m<n;m++)
{
printf("%d ",a[m]);
}
}
//chon truc tiep
void sapxep2(int a[],int n)
{
int min,t;
for(int i=0;i<n-1;i++)
min=i;
{
for(int j=i+1;j<n;j++)
{
if (a[i] > a[j])
min= j;
}
t=a[i] ;
a[i]=a[min];
a[min]=t;
}
for(int m=0;m<n;m++)
{
printf(" %d ",a[m]);
}
}
void main()
{
clrscr();
int a[30];
int n;
printf("Ban muon nhap bao nhieu phan tu:");
scanf("%d",&n);
nm(a,n);
printf("Mang vua nhap la:n");
xm(a,n);
printf("nMang duoc sap xep la:") ;
sapxep(a,n);
printf("nMang duoc sap xep la:") ;
sapxep2(a,n);
getch();
}

More Related Content

What's hot (19)

Numeros primos
Numeros primosNumeros primos
Numeros primos
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Sources
SourcesSources
Sources
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
 
Vcs6
Vcs6Vcs6
Vcs6
 
Union
UnionUnion
Union
 
Fibonacci
FibonacciFibonacci
Fibonacci
 
Heep implementation in c
Heep implementation in cHeep implementation in c
Heep implementation in c
 
Fcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt ChartFcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt Chart
 
Vcs21
Vcs21Vcs21
Vcs21
 
Programas for
Programas forProgramas for
Programas for
 
Cpro
CproCpro
Cpro
 
Pruebabfs
PruebabfsPruebabfs
Pruebabfs
 
Mcm
McmMcm
Mcm
 
listing output program C
listing output program Clisting output program C
listing output program C
 
bai tap-loi-giai-ngon-ngu-lap-trinh-c
 bai tap-loi-giai-ngon-ngu-lap-trinh-c bai tap-loi-giai-ngon-ngu-lap-trinh-c
bai tap-loi-giai-ngon-ngu-lap-trinh-c
 
Cg lab cse-vii
Cg lab cse-viiCg lab cse-vii
Cg lab cse-vii
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
 
Absolute Loader
Absolute LoaderAbsolute Loader
Absolute Loader
 

Viewers also liked

Atma karak, karkamsa & swamsa
Atma karak, karkamsa & swamsaAtma karak, karkamsa & swamsa
Atma karak, karkamsa & swamsaanthony writer
 
Direction
DirectionDirection
Directionyeunp
 
Justice League - Super Internet Heroes
Justice League - Super Internet HeroesJustice League - Super Internet Heroes
Justice League - Super Internet Heroesanandvivek2002
 
KLB4111
KLB4111KLB4111
KLB4111KLIBEL
 
ПР - инструмент устойчивости НКО
ПР - инструмент устойчивости НКОПР - инструмент устойчивости НКО
ПР - инструмент устойчивости НКОSelf-employed
 
лекарства 2 чеповецкий
лекарства 2 чеповецкийлекарства 2 чеповецкий
лекарства 2 чеповецкийirinaisaeva12
 
Проект мережі 14 -15
Проект мережі 14 -15Проект мережі 14 -15
Проект мережі 14 -15Vanya0508
 
Presentación1
Presentación1Presentación1
Presentación1quitianxz
 
10 Livros de Marketing e Social Media para ler em 2014
10 Livros de Marketing e Social Media para ler em 201410 Livros de Marketing e Social Media para ler em 2014
10 Livros de Marketing e Social Media para ler em 2014Helena Dias
 
Certificadodeamistad(e)
Certificadodeamistad(e)Certificadodeamistad(e)
Certificadodeamistad(e)manuel_30
 
Polo cuesta fotos-para o trabalho
Polo cuesta fotos-para o trabalhoPolo cuesta fotos-para o trabalho
Polo cuesta fotos-para o trabalhoMara Pedroso
 
Aviso de Inspección de Alcance Limitado remitido por el SEPBLAC a un despacho...
Aviso de Inspección de Alcance Limitado remitido por el SEPBLAC a un despacho...Aviso de Inspección de Alcance Limitado remitido por el SEPBLAC a un despacho...
Aviso de Inspección de Alcance Limitado remitido por el SEPBLAC a un despacho...Maria García Aguado
 
Aquienllevarias
AquienllevariasAquienllevarias
AquienllevariasLoly Lago
 
Algunos apuntes que nos quedan por dar, subrayado
Algunos apuntes que nos quedan por dar, subrayadoAlgunos apuntes que nos quedan por dar, subrayado
Algunos apuntes que nos quedan por dar, subrayadoLourdes Moreno Márquez
 

Viewers also liked (20)

Atma karak, karkamsa & swamsa
Atma karak, karkamsa & swamsaAtma karak, karkamsa & swamsa
Atma karak, karkamsa & swamsa
 
Direction
DirectionDirection
Direction
 
Added back page
Added back pageAdded back page
Added back page
 
Justice League - Super Internet Heroes
Justice League - Super Internet HeroesJustice League - Super Internet Heroes
Justice League - Super Internet Heroes
 
KLB4111
KLB4111KLB4111
KLB4111
 
Colloquium1a
Colloquium1aColloquium1a
Colloquium1a
 
Jun
JunJun
Jun
 
ПР - инструмент устойчивости НКО
ПР - инструмент устойчивости НКОПР - инструмент устойчивости НКО
ПР - инструмент устойчивости НКО
 
лекарства 2 чеповецкий
лекарства 2 чеповецкийлекарства 2 чеповецкий
лекарства 2 чеповецкий
 
Remache
RemacheRemache
Remache
 
Проект мережі 14 -15
Проект мережі 14 -15Проект мережі 14 -15
Проект мережі 14 -15
 
Krvna plazma
Krvna plazmaKrvna plazma
Krvna plazma
 
Presentación1
Presentación1Presentación1
Presentación1
 
10 Livros de Marketing e Social Media para ler em 2014
10 Livros de Marketing e Social Media para ler em 201410 Livros de Marketing e Social Media para ler em 2014
10 Livros de Marketing e Social Media para ler em 2014
 
Certificadodeamistad(e)
Certificadodeamistad(e)Certificadodeamistad(e)
Certificadodeamistad(e)
 
Polo cuesta fotos-para o trabalho
Polo cuesta fotos-para o trabalhoPolo cuesta fotos-para o trabalho
Polo cuesta fotos-para o trabalho
 
Aviso de Inspección de Alcance Limitado remitido por el SEPBLAC a un despacho...
Aviso de Inspección de Alcance Limitado remitido por el SEPBLAC a un despacho...Aviso de Inspección de Alcance Limitado remitido por el SEPBLAC a un despacho...
Aviso de Inspección de Alcance Limitado remitido por el SEPBLAC a un despacho...
 
caracteristicas del agua
caracteristicas del aguacaracteristicas del agua
caracteristicas del agua
 
Aquienllevarias
AquienllevariasAquienllevarias
Aquienllevarias
 
Algunos apuntes que nos quedan por dar, subrayado
Algunos apuntes que nos quedan por dar, subrayadoAlgunos apuntes que nos quedan por dar, subrayado
Algunos apuntes que nos quedan por dar, subrayado
 

More from tran thai

Báo cáo thực tập trần trọng thái
Báo cáo thực tập   trần trọng tháiBáo cáo thực tập   trần trọng thái
Báo cáo thực tập trần trọng tháitran thai
 
Báo cáo thực tập athena trần trọng thái
Báo cáo thực tập athena   trần trọng tháiBáo cáo thực tập athena   trần trọng thái
Báo cáo thực tập athena trần trọng tháitran thai
 
Báo cáo thực tập athena trần trọng thái
Báo cáo thực tập athena   trần trọng tháiBáo cáo thực tập athena   trần trọng thái
Báo cáo thực tập athena trần trọng tháitran thai
 
Báo cáo thực tập athena trần trọng thái
Báo cáo thực tập athena trần trọng tháiBáo cáo thực tập athena trần trọng thái
Báo cáo thực tập athena trần trọng tháitran thai
 
Báo cáo thực tập tuần 4
Báo cáo thực tập tuần 4Báo cáo thực tập tuần 4
Báo cáo thực tập tuần 4tran thai
 
Báo cáo thực tập tuần 4
Báo cáo thực tập tuần 4Báo cáo thực tập tuần 4
Báo cáo thực tập tuần 4tran thai
 
Báo cáo thực tập tuần 1
Báo cáo thực tập tuần 1Báo cáo thực tập tuần 1
Báo cáo thực tập tuần 1tran thai
 

More from tran thai (8)

3500
35003500
3500
 
Báo cáo thực tập trần trọng thái
Báo cáo thực tập   trần trọng tháiBáo cáo thực tập   trần trọng thái
Báo cáo thực tập trần trọng thái
 
Báo cáo thực tập athena trần trọng thái
Báo cáo thực tập athena   trần trọng tháiBáo cáo thực tập athena   trần trọng thái
Báo cáo thực tập athena trần trọng thái
 
Báo cáo thực tập athena trần trọng thái
Báo cáo thực tập athena   trần trọng tháiBáo cáo thực tập athena   trần trọng thái
Báo cáo thực tập athena trần trọng thái
 
Báo cáo thực tập athena trần trọng thái
Báo cáo thực tập athena trần trọng tháiBáo cáo thực tập athena trần trọng thái
Báo cáo thực tập athena trần trọng thái
 
Báo cáo thực tập tuần 4
Báo cáo thực tập tuần 4Báo cáo thực tập tuần 4
Báo cáo thực tập tuần 4
 
Báo cáo thực tập tuần 4
Báo cáo thực tập tuần 4Báo cáo thực tập tuần 4
Báo cáo thực tập tuần 4
 
Báo cáo thực tập tuần 1
Báo cáo thực tập tuần 1Báo cáo thực tập tuần 1
Báo cáo thực tập tuần 1
 

Bai lam chuong 3

  • 1. #include<stdio.h> #include<conio.h> void nm(int a[],int n) { for(int i=0;i<n;i++) { printf("a[%d]: ",i+1); scanf("%d",&a[i]); } } void xm(int a[],int n) { for(int i=0;i<n;i++) { printf(" %d ",a[i]); } } //doi cho truc tiep void sapxep(int a[],int n) { int t; for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) { if(a[i]>a[j]) { t=a[i] ; a[i]=a[j]; a[j]=t; } } for(int m=0;m<n;m++) { printf("%d ",a[m]); } } //chon truc tiep void sapxep2(int a[],int n) { int min,t; for(int i=0;i<n-1;i++) min=i; { for(int j=i+1;j<n;j++) { if (a[i] > a[j]) min= j; } t=a[i] ; a[i]=a[min]; a[min]=t; } for(int m=0;m<n;m++) { printf(" %d ",a[m]); } } void main() { clrscr(); int a[30]; int n; printf("Ban muon nhap bao nhieu phan tu:"); scanf("%d",&n);
  • 2. nm(a,n); printf("Mang vua nhap la:n"); xm(a,n); printf("nMang duoc sap xep la:") ; sapxep(a,n); printf("nMang duoc sap xep la:") ; sapxep2(a,n); getch(); }