0 like 0 dislike
2k views
有一個學生的結構如下

struct Student {

   int grade[20];

   int count;

};

grade 陣列裡儲存的是每位學生的成績, count 裡儲存的是該位學生共修習多少科目,請用這個結構實作以下函數。

int average_grade(struct Student s);

該函數傳入一個學生的結構,然後計算出該學生的平均後回傳。
[Exercise] Essay (Open question) - asked in 作業 by (18k points)
ID: 19748 - Available when: Unlimited - Due to: Unlimited

edited by | 2k views

20 Answers

0 like 0 dislike
Hidden content!
#include * * ****

struct student

{
* *** ** * **
* * * * * ** * * count;



};



int * ****

{
* * * * * average;
** ** ** * ***** student ****
** * **** *** * * * * **** * **** ******
* * * * *** * *** * * *** ***** ** *
**** *** ** * = ***** * / count;
*** **** * ** ** * * * * * **


* * * * * 0;

}
answered by (43 points)
0 like 0 dislike
Hidden content!
* * **** * ** * **
* ** * * *


*** * ** * * * * *
* ** * *** * count;

};

int main (void)

{
* * * ** * ** **

int i;

int sum=0;

float ave;
* ** ***** **** *** * *** *
** *** * * ** ***

{
* * ** ** *** ** * ** ** *
***** * **** *****

}
* **** *
* **** * ** ** * ** *
** 0;

}
answered by (-124 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

struct Student

{
* * ** * * **** grade[20];
** * * * * * count;

};

int average_grade(struct Student s);

int main()

{
**** * ** ** *** * **** * Student s;
* * *** * ** * * * * ** i;
** ** * * * * **** ** ** * * ** **** * ****
* * ** * * *** * * * *** * * **** *
* * * * *** * ** * *** * * ** * grade=");
* * *** **** * * * * ***** * **
* * * * ** *** ** **** * ***** * * * ** *
**** *** * **** ***** * ******* ** * ** * * ** ****

}



int average_grade(struct Student s)

{
*** *** ** * ** * ** * a;
* * ** * * ** ** * *** i;
* *** * **** * * * * * sum=0;
** * *** ***** *** * ** (i=0;i<s.count;i++)
*** * ** * ***** *
***** ** * ** * * * * * * ** * * *** *** **
******* *** * *
** ** * * * **** ** * ** **
* * * ***** * *** * * a;

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
#include ***** * * ***

#include * ***** **



struct Student {


** ** ******* grade[20];


** ***** ** count;



};



int * * * ***** Student s)

{
**** *** **** ** * i,a,sum;


***** **** ** *** * ***** * * * = 0;


* *** ** ********* * ******* ******* * **
* *** * * *** ** **** *
* ** **** **** *** ** * * ** * *** **** * * **** **
** * * * * * ** * * **
* * ** ** ** **** * = sum/s.count;
*** * **** * * ***** * *** ** a;

}



 



 



int main()

{


*** ** **** * * *** Student ** *** ** * **
**** ****** *** * * * *********** ***


**** *** * * * *** * * ****** ** ** ** ** * *
* * ** *** * ***** 0;

}
answered by (-186 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include<stdlib.h>

struct student{int grade[20];int count;};

int average_grade(struct student a)

{
* ****** * ***** ****** * c,i,j=0;
* * * * * ** * ** * ** ** * *** *
* * * **** * * ** * * ****** **
** * *** * * * ** * ** **
****** ******** * * *** **** ** j;
* ** ******* ** * ** *

int main(void)

{
**** * * * * * * * * student a;
** * ** * * * ** * ** * i,j,k;
***** * ** * ** * * * ** ** * **** *
** * ** * * **** *** *** *
**** ** *** * ** ** * ** * ***** * ** * *** *
**** *** * *** *** * ** ** ****
* * * * * ** * ** *
*** *** * * *** * *** * ***** * * *


* * * **** * * *** * 0;
* * **** * * *** ***
answered by (-122 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

struct Student

{
** ******* * **** * grade[20];
* *** *********** * count;

};

int average_grade(struct Student s);

int main()

{
** ** ***** * ** Student s;

* **** * * *** * * i;
* *** ** **** ** * ** * * * ** * * * * * ******
** * **** * **** **** *** * ** * * ** *
* *** * * * * * **** ** * * * * * **** ***** * ** *
* * * * ** ** * * ** * * * * **** * *****

}



int average_grade(struct Student s)

{
* *** ** * * * * * ** a;
** * ** * **** **** *** i;
** * ** ** *** sum=0;
** ** * ** * * * * * * **** *******
** * * * *** ** * * ***
* ** * * * *** ***** * * ***** ** **** ****
* ** ** ** ** * * *
*** * * * ** * * * **
* * * **** ** ** ** * a;

}
answered by (-124 points)
0 like 0 dislike
Hidden content!
int *** * *** * student s)

{
** * * *** * ****** * ** j =0 , k =0 , ave , i =0 ;
** * ** * **** * = 0 ; i < s.count ; i++)
*** **** * * * * * * * * ** ****** ***
* *** ** * ***** * * * * ** * * * ** ** * = s.grade[i] + j ;
* * * * ** ** * * * * * * ** * * = k ;
* ** *** ** * ** *** * *** * ** *** *
*** * * ***** * *** * ** * ***** ** * * = j/s.count ;
* * ** ** * * * ***** *** ** * * * * * *** *** ave ;

}
answered by (-87 points)
0 like 0 dislike
Hidden content!
** * * * *


*** * ** ** * ***


** ** * * ** **


* *** ** **


** **** ** * **


*** **



struct Student {


* * * * * *** *** * * * * *


* * **** * count;



};



int ** ** **** Student s )

{
* ** ** *** ** * *** ** * int b;int c = 0;int d;int a;


** ** *** * * *** ** * * * * ** *


**** ****** ****** ** * * = 0; a < b;a ++)
* * ** * * ******
* * *** *** ** *** ** * **** **** * ******* **** ** ** * * * ** ** * ** ** *
* ** * * * *
** ** * ******* *** ***** = 0; a * b;a ++)
** * ** *** * **** ****
** ** * * ** ** * ***** * * ** * = c + ** * *** * *
* ** ** ** ** **


****** * **** *** * = c / b;
****** * * ** * ** * * * * ** * ****

}


* * *



int main ( void )

{

struct Student s;


* * *** s );


*


* **



return 0;



}
answered by (-276 points)
0 like 0 dislike
Hidden content!
** * ** ** * **

struct Student {


** * * ** *** grade[20];


**** ** *** * ** count;



};
* * * *********** * *** * Student * **** ***

 {
*** * * * * **** *** ** *** ** Student average;
***** ***** ** * **** ***
* * ** * ** **** ** *** ** ** * *** **** ** *
*** *** *** ** *** * ***
* * * * *** **** * ** * *



 }
answered by (-143 points)
0 like 0 dislike
Hidden content!
#include



struct Student {
***** * * ** ** ** ** *
******** ** * * *** count;

};



int * * *** * Student s)

{
* * * * * * ** * ** i,sum;
** *** *** ** * *** * * ** * *** *
**** ** * ***** ** *** * * **** * ** = sum + * * *
**** * ** ** * * * * *
** * * * * * * ***** ** ** = sum / count;
* * * *** * * * sum;

}
answered by (-216 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.58.83
©2016-2025

Related questions

0 like 0 dislike
3 answers
[Exercise] Essay (Open question) - asked Dec 21, 2016 in 作業 by Shun-Po (18k points)
ID: 19755 - Available when: Unlimited - Due to: Unlimited
| 644 views
0 like 0 dislike
9 answers
[Exercise] Essay (Open question) - asked Dec 21, 2016 in 作業 by Shun-Po (18k points)
ID: 19753 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
0 like 0 dislike
0 answers
[Exercise] Essay (Open question) - asked Dec 28, 2016 in 作業 by Shun-Po (18k points)
ID: 20139 - Available when: Unlimited - Due to: Unlimited
| 419 views
0 like 0 dislike
82 answers
[Exercise] Coding (C) - asked Nov 23, 2016 in 作業 by Shun-Po (18k points)
ID: 17578 - Available when: Unlimited - Due to: Unlimited
| 5.8k views
0 like 0 dislike
26 answers
[Exercise] Essay (Open question) - asked Nov 9, 2016 in 作業 by Shun-Po (18k points)
ID: 17203 - Available when: Unlimited - Due to: Unlimited
| 2.6k views
12,783 questions
183,442 answers
172,219 comments
4,824 users