728x90
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j,sum,avg,k,t,a[9]={90,10,30,50,20,40,60,70,80};
do
{
sum=0;
for(i=0;i<9;i++)
{
sum+=a[i];
}
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
{
if(a[i]<a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
for(i=0;i<9;i++)
{
printf("%d ",a[i]);
}
avg=sum/9;
printf("\n평균 = %d\n",avg);
do
{
printf("수 = ");
scanf("%d",&k);
printf("\n");
if(k>100||k<10) printf("입력 잘못 \n");
}while(k>100||k<10);
if(k>avg) a[0]=k;
else a[8]=k;
}while(k>0);
return 0;
}
반응형