uj5u.com熱心網友回復:
供參考
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Student
{
char name[20];
int age;
int math;
int english;
int chinese;
float avge;
} Stu;
int main()
{
Stu s[3];
int i;
for (i=0; i<3; i++)
{
printf("輸入第%d個學生的姓名 年齡 數學成績 英語成績 語文成績:\n", i+1);
scanf("%s%d%d%d%d", s[i].name, &s[i].age, &s[i].math, &s[i].english, &s[i].chinese);
s[i].avge = (s[i].math + s[i].english+s[i].chinese) * 1.0 / 3;
getchar();
}
for (i=0; i<3; i++)
{
printf("%s學生的平均分為:%.2f\n", s[i].name, s[i].avge);
}
getchar();
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/67763.html
標籤:C語言
上一篇:程式是用來將用戶輸入的字母與數字混合的電話號碼變為純數字的,但程式在輸出電話號碼時確只輸出一個空格是怎么回事???還有一點,這個CSDN分數怎么給??
