AR1


TEST CASE 1 

INPUT
5
2 5 6 4 7
OUTPUT
6.5

TEST CASE 2 

INPUT
7
2 5 6 4 7 10 4
OUTPUT
8.5

#include <stdio.h>
int main() {
  int MAX =50;
  int array[MAX], i, largest1, largest2;
  int n,j,temp;
  float mean,sum;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&array[i]);
  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
      if(array[i]<array[j])
      {
      temp=array[i];
      array[i]=array[j];
      array[j]=temp;
      }
    }
  }
  largest1=array[0];
  largest2=array[1];
  sum=largest1+largest2;
  mean=(sum)/2;
  printf("%.1f",mean);
 return 0;
}

Comments

Post a Comment

Popular posts from this blog

SER12

AR15