//Chuong trinh tim so lon thu 2 trong mang
#include<stdio.h>
#include<conio.h>
void nhap(int a[20],int n)
{
int i;
printf("\nNhap cac phan tu cho day:");
for(i=0;i<n;i++)
{
printf("\nNhap phan tu a[%d]: ",i+1);
scanf("%d",&a[i]);
}
}
void xuat(int a[20],int n)
{
int i;
printf("\nDay vua nhap la: \n");
for(i=0;i}
void MaxThu2(int a[20], int n)
{
int i,j=0,z;
for(i = 0; i < n; i++)
{
for(j = i+1; j < n; j++)
{
if(a[i] > a[j])
{
z = a[i];
a[i] = a[j];
a[j] = z;
}
}
}
for(i = n-1; i >= 0; i--)
{
if(a[i] > a[i-1])
{
printf("Gia tri lon thu nhi trong mang la: %d\n", a[i-1]);
break;
}
}
}
main()
{
int n,a[20];
lap:
clrscr();
printf("\nNhap so phan tu cho day: ");
scanf("%d",&n);
nhap(a,n);
MaxThu2(a,n);
getch();
goto lap;
}