baitap18
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
int mang[5];
int copy[5];
main()
{
int i,j,dem=0,c;
for (i=0;i<5;i++)
{
printf("nhap vao phan tu %d ",i);
scanf("%d",&mang[i]);
}
for (i=0;i<5;i++)
printf("%d ",mang[i]);
//------------------------------------------------------------
for (i=0;i<=3;i++)
for(j=i+1;j<=4;j++)
if (mang[i]<=mang[j])
{
c=mang[i];
mang[i]=mang[j];
mang[j]=c;
}
puts("
sap xep theo gia tri giam dan
");
for (i=0;i<5;i++)
printf ("%d " ,mang[i]);
//--------------------------------------------------------------
for (i=0;i<5;i++)
{
if (mang[i]%2==1) dem++;
if (dem==2)
{
printf("so le lon thu 2 la%d",mang[i]);
break;
}
if (dem!=2) puts("khong co den 2 so le");
}
getch();
}
Bạn đang đọc truyện trên: Truyen247.Pro