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

struct Student {

   int grade[20];

   int count;

};

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

int average_grade(struct Student s);

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

23 Answers

0 like 0 dislike
Hidden content!
int ***** * * ** Student s)



{


*** ** * * ** * ** i , sum = 0 ;


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


**** * ** * *** * ** *** **** ** ** ** += s.grade[i];


** **** * * *** * *** * ** * * * ** * ;



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



#include **** ** ** **



#include * * * ** *



#include * * ** *



struct Student {


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


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



};


** ** **



int ** * * * Student s)



{


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


* ** * **** * ** *** ** ** average = 0,sum = 0;


**** **** *** * * (i = 0;i < * ***


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


*** *** ** ** ** * * * * * * * * += * * * * *** * *


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


* ** * * * *** ** ** = sum / ** * *


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



}



int * * *



{


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


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


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



*** ** * * * * * ***** * (i = 0;i < * *******


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



}


* ** **


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



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

struct Student {


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


** * * * ** count;



};

int * * * ** * Student s)
**** * ** * ****
* *** * * ******** * * s, i, sum,avg;
* * ******** **** * * ** ***** * ** (i=0; i<s.count; i++);
****** * * ** * * * ** * * * *** *** ** *
* * * ***** ** * * ** * ** * * * * = sum/s.count;
** ** * ** * ****** ** * * ****** avg;
* * *** ** * ****
answered by (-110 points)
0 like 0 dislike
Hidden content!
** * *
* * *** * * ** **


* * *



struct Student {


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


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



};
** * ***

int ** * ** Student s)

{
* * * ** *
* * * ** * *** ** * *
***** * * * ** *
** ** * *** *
** ** * * c;

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



{


* * ** *


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


**** * * *


**** *** * ***


**** * c;



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

#include *** ** * ** * *

struct Student

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

};

int ** * Student s)

{
***** * * * * *** * * sum , i , c;
** *** ** ** ** * * *** ** * *** **
* * ** **** * * * *** * = sum + * * ***
** * ***** * *** *** ** = *** **
* * ***** ***** **** * ** c;
** ** * * *** **

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

{
**

** * *** * ******
* ** **
* ** ** * *
** * * ans;

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

#include *** * * *

struct Student

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

};

int * ** * ** Student s);

{
* * * ** * ***** * * * * sum , i , c;
*** ***** * * * ** **** * ** ** ** *
* * *** ** ** * = sum + *** * *
* ** * * **** * * * ** = ***
** *** * ****** * * * *** * ** c;
* * **** **** ** *

}



int * * *
* **
** ***** * Student;
** * i , grade[20];
* ** * * *** * **
**** ****** * * , ** *
* * *
* *** **** * * ** ***
* ** *** 0;
**
answered by (-194 points)
0 like 0 dislike
Hidden content!
int * **** * * Student s);

{
* * *** * * **
* * * ** *** * ****
** * ** * ** *
* * *** *
**** * * * ** c;

}
answered by (-146 points)
0 like 0 dislike
Hidden content!
int average_grade(struct student s)

{

    

   
*** **** * * *** *** * **** * **** * * * ** * **** * * ** * *** * average=0;
** * * * * * * *** ** *** * * *** * ** *** *** ** * sum=0;
** ** * ** * ** *** ** * ** * * **** * **** * **** * i;
* * * *** ** *** ****** * * ** *** ***** ** * *** * * * ** ** * ** * * * * * *
****** * * * * ** * * *** * * *** * ** * ** * *** * *** * **** = sum + s.grade[i];
* ***** *** ** ** * *** * ***** * * * *** ** * * * *** = sum / s.count;
** * ** * ** **** ** ***** * * * *** ***** * ** ** * * average;

}
answered by (-188 points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.63.143
©2016-2020

Related questions

0 like 0 dislike
7 answers
[Exercise] Essay (Open question) - asked Dec 22, 2016 in 作業 by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 102 views
0 like 0 dislike
65 answers
[Exercise] Coding (C) - asked Nov 24, 2016 in 作業 by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 375 views
0 like 0 dislike
20 answers
[Exercise] Essay (Open question) - asked Nov 10, 2016 in 作業 by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 199 views
0 like 0 dislike
26 answers
[Exercise] Coding (C) - asked Nov 3, 2016 in 作業 by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 199 views
0 like 0 dislike
37 answers
[Exercise] Coding (C) - asked Oct 20, 2016 in 作業 by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 196 views
10,943 questions
124,821 answers
118,847 comments
3,819 users