https://www.hackerrank.com/challenges/mini-max-sum/problem
#include<stdio.h>
int main()
{
long a[5],l,a1;
int i,j;
for (i=1;i<=5;i++)
{
scanf("%ld",&a[i-1]);
}
for (i=0;i<5;i++)
{
l=a[i];
for(j=i;j<5;j++)
{
if(a[j]<l)
{
a1=l;
l=a[j];
a[j]=a1;
}
}
a[i]=l;
}
printf("%ld ",a[0]+a[1]+a[2]+a[3]);
printf("%ld",a[1]+a[2]+a[3]+a[4]);
return 0;
}
No comments:
Post a Comment