Enter grades 6, bubble sort, averaged points, and then find the average score is greater than, the final results will be displayed in the even

/ *
================================================ ============================
the Name: bubble_sort.c
Author: duanqibo
Version:
Copyright: Your Copyright Notice
the Description: enter the six grades, bubble sort, averaging points, and then find the fraction is greater than the average of the last will be displayed in the results even
========================= ================================================== =
* /

#include <stdio.h>
#include <stdlib.h>
//实现排序
void sort(int s[],int n)
{
int i,j,temp;
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(s[j]>s[j+1])
{
temp=s[j];
s[j]=s[j+1];
s[j+1]=temp;
}
}
}
}


int main (void) {
int I;
int Score [. 6];
Setbuf (stdout, NULL);
the printf ( "Please enter 6 Results:");
for (I = 0; I <. 6; I ++) // loop input 6 results
{
Scanf ( "% D", & score [I]);
}
// sort
sort (score, 6);

printf ( "\ n sorting results: \ n-");
for (I = 0; I <. 6; I ++) // loop input 6 results
{
the printf ( "% 3D", Score [I]);
}

// Find the even
printf ( "\ n is even results in: \ n-");
for (I = 0; I <. 6; I ++)
{
IF (Score [I]% 2 == 0)
the printf ( "% 3D ", Score [I]);
}

// find the average score is greater than
int = 0 SUM, AVG = 0;
for (I = 0; I <. 6; I ++)
{
SUM = SUM + Score [I];
}
AVG = SUM /. 6;
the printf ( " \ n average: \ n ");
the printf ("% D ", AVG);
the printf (" \ n greater than the average scores have: \ n ");
for (I = 0; I <. 6; I ++)
{
IF (Score [I]> AVG)
the printf ( "% 3D", Score [I]);
}
return. 1;
}

Guess you like

Origin www.cnblogs.com/duanqibo/p/11105082.html