查看單個文章
舊 2002-12-13, 03:47 PM   #12 (permalink)
mider0917
榮譽勳章

勳章總數
UID -
在線等級:
文章: n/a
精華:
預設

#include<stdio.h>

void main()

{
int grade[5][5] = {
{80,88,93},
{76,74,81},
{58,66,64},
{63,73,71},
{77,92,90}};

int i , j , sum1,sum2,sum3,sum4,sum5;
float ave1,ave2,ave3,ave4,ave5;
for (i=0;i<5;i++)
{
for(j=0;j<3;j++)
{
printf("%-3d",grade[i][j]);
}
printf("\n");
}
sum1 = grade[0][0] + grade[0][1] + grade[0][2];
ave1 = (float)sum1/3;
sum2 = grade[1][0] + grade[1][1] + grade[1][2];
ave2 = (float)sum2/3;
sum3 = grade[2][0] + grade[2][1] + grade[2][2];
ave3 = (float)sum3/3;
sum4 = grade[3][0] + grade[3][1] + grade[3][2];
ave4 = (float)sum4/3;
sum5 = grade[4][0] + grade[4][1] + grade[4][2];
ave5 = (float)sum5/3;
printf("The first student's average is ===>%3.2f \n",ave1);
printf("The second student's average is ===>%3.2f \n",ave2);
printf("The third student's average is ===>%3.2f \n",ave3);
printf("The fourth student's average is ===>%3.2f \n",ave4);
printf("The fifth student's average is ===>%3.2f \n",ave5);
{
int sum6,sum7,sum8;
float ave6,ave7,ave8;
sum6 = grade[0][0] + grade[1][0] + grade[2][0] + grade[3][0] + grade[4][0];
ave6 = (float)sum6/5;
sum7 = grade[0][1] + grade[1][1] + grade[2][1] + grade[3][1] + grade[4][1];
ave7 = (float)sum7/5;
sum8 = grade[0][2] + grade[1][2] + grade[2][2] + grade[3][2] +grade[4] [2] ave8 = (float)sum8/5;
printf("The all class's Math average is ===>%3.2f \n",ave6);
printf("The all class's English average is ===>%3.2f \n",ave7);
printf("The all class's Electronics average is ===>%3.2f\n",ave8);
}

{
int i,j,tmp;
int num[5] = {ave1,ave2,ave3,ave4,ave5};


for(i=0;i<2;i++)
{
for( j=0;j<4;j++)
if (num[j]>num[j+1])
{
tmp = num[j];
num[j]=num[j+1];
num[j+1] = tmp;
}
printf("\2:loop %d ",i);
for(j=0;j<5;j++)
printf("%4d",num[j]);
printf("\n");
}
printf("\2:排名 %d %d %d %d %d \n",5,4,3,2,1);
}

}
==============================================
這ㄍ是小弟滴程式........= =''請幫忙想辦法一下~~~~拜託ㄌ.......我一直丟不進ㄑ~~QQ"~~~
 
送花文章: 0, 收花文章: 0 篇, 收花: 0 次
回覆時引用此帖