View Code of Problem 76

#include <stdio.h>
int main(){
  int a[10];
  int m;
  int i,j;
  for(i=0;i<9;i++){
    scanf("%d",&a[i]);
  
  }
  scanf("%d",&m);
  if(a[8]>a[0]){
    for(i=0;i<9;i++){
      if(a[i]>m){
        for(j=8;j>=i;j--)
          a[j+1]=a[j];
      }
      a[i]=m;
    }
  
  }else{
    for(i=0;i<9;i++){
      if(a[i]<m){
        for(j=8;j>=i;j--)
          a[j+1]=a[j];
      }
      a[i]=m;
    }
  
  }
  for(i=0;i<10;i++)
    printf("%d\n",a[i]);

return 0;
}

Double click to view unformatted code.


Back to problem 76