#include
10年積累的成都網(wǎng)站建設(shè)、做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有江山免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
float
aver(float
sum){
sum=sum/5;
return
sum;
}
main()
{
int
a,b,c=1,ave,l,y;
float
sum=0;
for(a=0;a5;a++)
{
for(b=0;b5;b++)
{
printf("請(qǐng)輸入第%d名學(xué)生的第%d課程各的成績(jī):\n",c,b+1);
scanf("%d",l);
sum=sum+l;//這里將c改成l
}
printf("第%d門(mén)課的平均成績(jī)?yōu)椋?f\n",c,aver(sum));
printf("\n");
c++;//這里用分號(hào)換行
sum=0;
}
}
//還有將sum定義為float類型
代碼文本:
#include "stdio.h"
double tol_ave(int a[],int n,int *s){
int i;
for(*s=0,i=0;in;*s+=a[i++]);
return *s/(n+0.0);
}
void level(int a[],int n){
int v,g,m,p,f;
for(v=g=m=p=f=0,n--;n=0;n--){
v += a[n]=90;
g += a[n]=80 a[n]90;
m += a[n]=70 a[n]80;
p += a[n]=60 a[n]70;
f += a[n]60;
}
printf("優(yōu)秀\t良好\t中等\t及格\t不及格\n");
printf("======================================\n");
printf(" %d\t %d\t %d\t %d\t %d\n",v,g,m,p,f);
}
int main(int argc,char *argv[]){
int sum,a[1000],i,n;
double ave;
printf("輸入學(xué)生人數(shù):");
if(scanf("%d",n)!=1 || n1 || n1000){
printf("Input error, exit...\n");
return 0;
}
printf("請(qǐng)輸入%d個(gè)學(xué)生的成績(jī)...\n",n);
for(i=0;in;scanf("%d",a+i++));//輸入成績(jī)
ave=tol_ave(a,n,sum);
printf("\n總? 分:? %d\t平均分:? %.2f\n",sum,ave);
printf("\n等級(jí)分布如下:\n");
level(a,n);
putchar('\n');
return 0;
}
#include?stdio.h?
#define?N?100
/*定義學(xué)生結(jié)構(gòu)體*/????
struct?Student????
{????
int??ID;???
char?Name[20];???
float?Mark1;????
float?Mark2;??
float?Mark3;?
float?Sum;????
};???
/*聲明學(xué)生數(shù)組及學(xué)生數(shù)量*/????
struct?Student?students[N];????
//int?num=0;??
/*求總分*/????
float?Sums(struct?Student?stu)???
{????
return?stu.Mark1+stu.Mark2+stu.Mark3;??
}????
/*輸入學(xué)生信息*/????
int?Student_Input(){??
int?num=0;
while(1){????
//printf("請(qǐng)輸入學(xué)號(hào):");???
students[num].ID=num+1;?//可以自行將學(xué)號(hào)改為手工輸入
printf("請(qǐng)輸入姓名:");?
scanf("%s",students[num].Name);??
getchar();??
printf("請(qǐng)輸入成績(jī)1:");?
scanf("%f",students[num].Mark1);?
getchar();??
printf("請(qǐng)輸入成績(jī)2:");?
scanf("%f",students[num].Mark2);?
printf("請(qǐng)輸入成績(jī)3:");?
scanf("%f",students[num].Mark3);?
getchar();??
students[num].Sum=Sums(students[num]);???
num++;??
printf("是否繼續(xù)?(y/n)");?//繼續(xù)輸入數(shù)據(jù)?
if?(getchar()=='n'){??
break;??
}????
}??
return?num;??
}??
/*輸出學(xué)生信息*/???
void?Student_Display(int?n)???
{???
int?i;????
printf("%10s%10s%8s%8s%8s%8s\n","學(xué)號(hào)","姓名","成績(jī)","成績(jī)","成績(jī)","總成線");??
printf("---------------------------------------------------------\n");??
for?(i=0;in;i++)??
{??
printf("%10d%10s%8.2f%8.2f%8.2f%8.2f\n",students[i].ID,students[i].Name,??
students[i].Mark1,students[i].Mark2,students[i].Mark3,students[i].Sum);??
}??
}?
/*主程序*/????
int??main(){?
int?n=0;
n=Student_Input();
Student_Display(n);?
return?0;??
}
if(maxa[i][j])
max=a[i][j];
l=j;
h=i;//找到最大值后,鎖定行與列//
缺少大括號(hào),只有max=a[i][j]是在if條件為真的判斷里執(zhí)行,l和h在每一次循環(huán)都被賦值