theo ý tưởng của một bạn trên diễn đàn, mình không nhớ ở đâu nữa, mình góp thêm cho vui:
PHP Code:
#include <stdio.h>
#include <conio.h>
void main()
{
float max1, max2, min1, min2, temp;
printf("Nhap vao day so:");
for(int i=0; i<5; i++)
{
scanf("%f", &temp);
if(i==0) max1=min1=temp;
if(i==1&&max1<temp) max2=max1, max1=temp;
else if(i==1) max2=temp;
if(max1<temp) max2=max1, max1=temp;
else if(max2<temp) max2=temp;
if(i==1&&min1>temp) min2=min1, min1=temp;
else if(i==1) min2=temp;
if(min1>temp) min2=min1, min1=temp;
else if(min2>temp) min2=temp;
}
printf("%f la so lon thu hai, %f la so nho thu 2!", max2, min2);
getch();
}