#include<stdio.h>
typedef struct{
char name[20];
int score[3];
}student;
const int number=10;
student *student_input(student *pstudent){
scanf("%s",&pstudent->name);
int i=0;
for( i=0;i<3;i++){
scanf("%d",&pstudent->score[i]);
}
return pstudent;
}
void student_print(const student *pstudent){
double avg=student_averge(pstudent);
printf("%d",pstudent->name) ;
int i;
for(i=0;i<3;i++){
printf("%d",pstudent->score);
}
printf("%.5f",avg);
}
void student_average(const student *pstudent){//求學生三科成績平均值函式,需要傳入一個地址
double sum=0.0;
int i;
for(i=0;i<3;i++){
sum+=pstudent->score[i];
}
}
int main(){
printf("請輸入學生姓名和各科目成績\n");
student student[number];
student *pstudent;
pstudent=&student[0];
int i;
for(i=0;i<10;i++){
pstudent=student_input(&student[i]);
pstudent++;
}
printf("No\tname\tscore1\tscore2\tscore3\t");
pstudent=&student[0];
for(i=0;i<number;i++){
student_printf(pstudent);
pstudent++;
}
return 0;
}
報錯
C:\Users\yhxc\Desktop\C語言程式\統計班級同學成績.c In function 'main':
34 11 C:\Users\yhxc\Desktop\C語言程式\統計班級同學成績.c [Error] 'pstudent' undeclared (first use in this function)
34 11 C:\Users\yhxc\Desktop\C語言程式\統計班級同學成績.c [Note] each undeclared identifier is reported only once for each function it appears in
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/206181.html
標籤:C語言
上一篇:用Cmake構建PCL庫遇到LNK2019的問題,原始碼來自PCL教程的ensenso_cameras
下一篇:c語言
