0 喜歡 0 不喜歡
1.4k 瀏覽

Write a program with following requirements:

  • Define the structure type student with fields: name, code, and grade.
  • Write a function to sort the structures in grade ascending order and another function to display the data of the students who got a higher grade than the average grade of all students. If there is only 1 student in the list, display the data of that student.
  • Write a program that uses this type to read the data of 100 students and store them in an array of such structures. If the user enters the grade −1, the insertion of student data should terminate. Then print the data of the students who got a higher grade than the average grade of all students. 

 Example input:

Edgar
20161123
78
Robert
20161523
75
Rebecca
20166123
66
Todd
20161673
86
End
1
-1

Example output:

Students who got a higher grade than the average grade of all students:
Name: Edgar
Code: 20161123
Grade: 78
Name: Todd
Code: 20161673
Grade: 86
[考試] 最新提問 分類:Midterm |
ID: 24273 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.4k 瀏覽

8 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include ******* ** *

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



struct student_grade

{
* ** *** ** * ** ******** code[100], grade [100];
* ** ** * * ***** * ** **

};

int main()

{
*** * * *** * ** * ** sum=0;
*** *** **** * ** *** * * i, j;
** * * * **** *** ******* *** ** student_grade s1;


** **** * ** ** * * ** * i<100; i++)
* * ** * **** * *
* * *** * ****** **** * * ** ** * **** *** ** * ** * %d %d", s1.name[i], * ***** ***** *** ** * **
* * ** *** ** *** *** ** * *** * ** * ** **** * **
***** * ** * * * ** * * ** * * ***** * ** * * * ** * * *
*** * *** * ** ** * * ** ** * * * * ** * * * * * * *** **
*** ** * **** *


* ** ***

{
* ** ** ** ****** **** * ** * * * ***** who got a higher grade than the average grade of all * **** *** **

}

for(j=0; j<i; j++)

{
* **** * ** * ** ** * * ** * *** * *
** * **** ** * ** ** ** **
* * ** * * * ** ** *** * * ** * * *** * %s\n", s1.name[j]);
**** * **** * *** * **** *** * * * * * ** * * ** ** * * s1.code[j]);
** ** ** **** **** *** ** * ** * ** **** * * * * ** ** ** * %s\n", s1.grade[j]);


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

}

}
最新回答 用戶: (-48 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ** *** *** *

#include **** ** *

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

#define MAX 100



struct student{

char name[25];

int id;

int grade;





};





void sort(struct student e[],int n){

int i;

int j;



for * **

for * * *
* ** * * ** ** * *** ** ** * *** * * ** * ** * * **** * * ***
**** * * **** * ** ** * *** ** * * * **** **** *** * * * * student temp=e[j];
* *** ** ** * * ***** * * * *** *** * * * ** * *** * * *** *** * ***
*** ** * *** * * * ******** *** *** * * * **** ** * * * ** * * ****
*** * * ** * * * * * * ** ****** *** ** * *



}





}

}

void **** ** student e[],int n){

int i;

int avr=0;



for ** ** ** *
* *** * ** ** * **** * * ** ****

}

avr=avr/n;

for * ** *** *
*** * *** * ** * * * *** * ** **
* *** ** * * ** * * * ** ** * * * ** * * ** *
*** * * * **** * ****** ** * * * * * * ** *
* ** ** *** * ** * * ** ** * ** * *** *
* ** ** * * ** ***

}

}





int main(){



struct student e[MAX];

int n;

int i;



for * **
* ***** * ** * * ***** ** ** * ** * ** * ** ***
** * ***** ** * * * **** *** ** * **** ** ** * *
* * * ** * * ****** * * * *** ** * * *
* **** * * * ** * * *** ***
* ** * *** ** ** ** * ******** *** * ** * * * * *

}

}

n=i;

if (n==0)
* * *** ** **** ***
**** ** * **** ** ** ** **** * * ** **
* *** ***** ** * **** *** *** * * *
*** * ** **** * *** * **** ** * * * ** * * * * ** * *
* **** * * **** * ** *

else

{


* *


* ** * ** who got a higher grade than the average grade of all ** * *


* ** *

}

return 0;}
最新回答 用戶: (-34 分)
0 喜歡 0 不喜歡
內容已隱藏
#include * ** ** *

#include * * * **

#define MAX_STR 50

#define MAX_STUD 100



typedef struct{
* *** ** ** ** ** * name[MAX_STR];
** ** * ** ** ** *** code;
** ** * *** ******* * * * grade;

}Student;



int main(void){
* ** *** * * ** * * * * ** ***** *
* ** * ** * **** *** ** * i, count=0, sum=0;
* ** * ** * *** ** * *** avg;


** * ** *** ** *** ** * ** i<MAX_STUD; i++){
* ******* ***** ** ** ** ** * *** ** ***** ** ** * ** * * ** * ** ** **** * ** ** *******
* ** *** * ** ** ** ** ** ** * ** * ** ** * * *** * ** * * ***** **
* **** *** * * *** ** * ** * * * * * ** * * * **** ** * **** * * ** ** * **
** * ***** * *** * ** *** ** ** *** ** *
* * * ** * ** * ** * *** *** **** * * * * += students[i].grade;
* * **** * **** * *** * * * * **** **** * * ** ******** * == -1)
*** * * ** ** * * * ** ** ** *** * * * * * *** ****** * *******
**** * * *** * **
* *** * ** * * * = (sum+1)/(count-1);
* * * *** *** * * **** **** * * who got a higher grade than the average grade of all * * * **


* *** ** *** ** * * * ** ** i<count; i++){
***** ** ** *** * * * ** * * * * * * * *** * * ** > avg)
** ** * ** ** ** ** * * **** ***** * ** ** * ** * * *** * %s\nCode: %d\nGrade: %d", students[i].name, students[i].code, *** ** *
***** **** * *** * * *


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

}
最新回答 用戶: (20 分)
0 喜歡 0 不喜歡
內容已隱藏
#include * * * * *

#include * ** ** * *



struct Student{
********* *** * *** **** name[20];
** * * * **** ** *** id[20];
* * ** * ** *** * ** grade;

};



typedef struct Student Student;



int main(){
**** ** ** * *** ** ** i;
* * * ** **** **** lenght = 0;
* * ** * ** *** * * total = 0;
** *** ** * * *** * * average = 0;
** * ** *** *** * * ** ** list[100];


* ** * * * * *** ** * ******* i<100; i++){
* * ******** *** * * *** **** * ******* ***** ** *** list[i].name);
** ** * *** ** ** * **** * ** * * ** * *** * ***** * list[i].id);
*** * **** ** ** **** *** * ** * * ** * * ** * **
* * * * * * * * ** ** * * ** ** * ***** ** ** * * < 0)
* * ***** * ** * *** ** *** * * ****
** *** ** * * * ****


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


* *** ** * * ** * ** i< lenght; i++){
** **** **** * * ** * * ** *** * **** += list[i].grade;
** * * * ** ** * *******


* * * ** ** * ** **** ** = total / lenght;


* ** * *** * ** * *** * *** who got a higher grade than the average grade of all ****** *** *
* * * * ** * * * * ** *** * * i++){
* ** * ******** *** * * * ** * * * * * * * *** ** > average){
** * **** * * ** * ** * * * *** ** * ** * * ** * **** ** ** * *** * ** * ** * ** %s\n", list[i].name);
* *** *** * * * * ** ** **** * *** ** * * ****** ** **** * * ***** * %s\n", list[i].id);
* * * * ***** **** * * * *** * * * ** *** * ** * * ***** * ** %d\n", list[i].grade);
** * * ** ** **** ** *** * ****** ***
*** ** *** * * ***


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

}
最新回答 用戶: (-188 分)
0 喜歡 0 不喜歡
內容已隱藏
#include **** *** **** *

#include * ** * **** *



struct Student{
* * * * ** ** * *** name[20];
* * ** ** * * ** ** **** * id[20];
** ******** *** ******* ** ** grade;

};



typedef struct Student Student;



int main(){
* ** * * * * * * * * * i;
**** * *** ** ** lenght = 0;
*** *** * *** ***** *** * total = 0;
*** ** *** * *** **** * **** average = 0;
*** ***** *** * ** * * list[100];


* ****** * * *** * * * * ** * i<500; i++){
** ** * * * ** * * ** ** * * ** ** list[i].name);
** ** * ** ** *** **** *** * * * * * **** *** ** list[i].id);
*** * *** * * ** * **** * * ** * * * *** ** ** * * ** * * *
* * * *** * **** * * * ******* * < 0)
*** * * ** * ** * ***** ** * ***** ** *** **
** * ** * * ******


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


* ** * * *** ******* ** * i< lenght; i++){
* * *** ** ** * * * * ** ** *** * * *** += list[i].grade;
* ** ** * * *** ** * *


** * * * * * ***** ** ** ** = total / lenght;


* * * **** * * * ** ** * ** who got a higher grade than the average grade of all * ***** ***
** ** * * * * * * * ** *** * ** i++){
*** * ***** * ** * * ** * * * * * ** *** * * > average){
* * ** * ** ***** *** * * *** **** * ** ** * * * *** ** * * ** * * ***** * * * %s\n", list[i].name);
* ** * * *** * *** ** **** **** ** * * * * ** * * * **** * * * * ** %s\n", list[i].id);
*** * *** * * ** * * * * * ** * * **** ** * *** ****** * **** * *** ****** ***** * %d\n", list[i].grade);
* ** * ** ** * * * * ** * * ***** *** *
* * ******* * ** ** ** *


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

}
最新回答 用戶: (-188 分)
0 喜歡 0 不喜歡
內容已隱藏
#include * *** * ** *

#include * ** * * * **



struct Student{
* * ** * ** ***** ** *** name[20];
** ***** ***** * ****** * * id[20];
* ** ***** * * ** ** * grade;

};



typedef struct Student Student;



int main(){
* ** * ** * * ***** ** i;
***** * ** * * **** lenght = 0;
* * ** * * **** * *** total = 0;
* *** * * *** **** * * ** average = 0;
** **** *** * * *** ** ** * * list[100];


*** * * * * ** * * **** ** * i<500; i++){
*** **** * * ** *** *** ** * * **** * * *** * * list[i].name);
** * ***** ******** *** * * *** * * * ** * ** *** list[i].id);
** * * * * * * * * *** * ** ** ** **** * * *** * * * ** * *
** *** * * * *** * * ** ** * ** * * * < 0)
* * ** ***** **** ***** * ** * ** ** * * **** * * *
*** * * ** *** **


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


* ** ** * * * ******** * i< lenght; i++){
** * * * *** * ** ** * ** * ** *** ** * * ** += list[i].grade;
*** **** **** ** **** *


** **** * *** *** * ** * = total / lenght;


* **** *** * **** * * * * *** * * * * who got a higher grade than the average grade of all ******** ** *
* * * ** **** *** * * * ** ** * *** ***** i++){
** ****** ** * **** * *** * ********* ** * ** > average){
***** * * * ** ***** * * *** * * * * ** * *** * ** * **** * *** * **** %s\n", list[i].name);
** ** * ** * * * **** * * *** ** * * * * ** * ** * **** * *** ** *** * ** * %s\n", list[i].id);
** ** *** * ** * ***** **** ** ** * * ******** **** **** ** %d\n", list[i].grade);
** **** **** * ** * * **** *** * **** * * ** **** *
**** *** * * *** *


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

}
最新回答 用戶: (-188 分)
0 喜歡 0 不喜歡
內容已隱藏
#include * * * ** *

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



struct Student{
** *** *** * ** ** * ****** name[20];
* * * * *** * *** ***** * id[20];
*** * * *** ** * grade;

};



typedef struct Student Student;



int main(){
* * * * * ** * ** *** * ** i;
** * * * * *** ** * * lenght = 0;
*** * ** **** ***** * * * total = 0;
*** * ** * * **** * * * average = 0;
* **** **** ** * *** list[100];


* * ** * * * ****** * * ** * * i<500; i++){
* **** * * *** * * * * * * *** * * * ** ** * list[i].name);
* * * ** * * * **** ** * * * * ** * ** * * list[i].id);
****** ** * * * * * * ** ** * **** *** * * * ** ** *
**** * ** ** ** * * * * *** * * * * * * * * == -1)
* * * **** ** ** * ** * ** * * **** ** *** * * *
* ** ** ***** ***


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


** ******** * ** * **** * i< lenght; i++){
*** ** * ** *** * ** * ** *** ** * * *** *** * += list[i].grade;
**** ** **** * * **


**** * ******* * ***** ** = total / lenght;


** ***** * * ** * * *** * * ** **** * who got a higher grade than the average grade of all *** ** ** ***
** ** ** * *** * ** * * * * ** ** i++){
** * * * * *** *** * **** * * *** * * * > average){
* ** * *** *** ******* *** * ** * * * ** * * ** ** * * * ** %s\n", list[i].name);
* * *** * ** *** ** * **** ** ** * ** * ** ***** * ***** *** * * %s\n", list[i].id);
***** ********* *** *** ** ******** * ** * * * * * * * * * * * %d\n", list[i].grade);
****** * * * * ** * * *** * * **
*** ** * * * ** * * ***


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

}
最新回答 用戶: (-188 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

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



struct Student{
* ** * * ** ****** ** ** name[20];
* * ** * * * * * id[20];
* ** * ** * ** ** * * grade;

};



typedef struct Student Student;



int main(){
* * ********** ** * i;
* * *** **** ** lenght = 0;
** *** *** * ** **** ** average = 0;
* ** ** * ** * ** **** * * list[100];


* * * ** *** * * * ** * i<100; i++){
*** ** * *** *** ** * *** *** * ****** * * **** * ** * list[i].name);
***** * * *** ***** ** *** * * * ** ** * * list[i].id);
* ** * * ***** ** * * ** * * * *** * * ** ** * *** ** * *
* ** ** *** **** * * **** ** ** *** ** * == -1)
* *** ** **** * * * * * * ** ** *
** * * * ** *** ******


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


*** * * ****** * * * * *** i<lenght; i++){
** * * * * * * ** *** * *** **** *** ***** ** * ** **** list[i].name);
* ** *** * * * **** * * * * * * * * *** ** ** * *** *** * ** * list[i].id);
* * *** * ** ***** * ****** * * ** ******* * * ** * list[i].grade);
* *** * * * * ** *


* ***** * *** * * * ******** ***** i< lenght; i++){
* * * **** * * *** * * ****** += list[i].grade;
* * **** **** ** ** ** * **


* * **** ** * * ** * ** * = average / lenght;


** ** ** * ** * * * ** ** who got a higher grade than the average grade of all students:\n");
** * * *** **** ** *** i<lenght; i++){
**** ** * ******* * ** **** * * ** * * * ********* * * > average){
** *** ** *** * * ** * *** * * *** **** * * * * * * * * ***** **** * ** list[i].name);
* ******** ** * * *** * ** ******** *** **** ** *** * * ***** * **** * list[i].id);
** * * * * * ******* *** *** * *** ***** **** * ** * **** * * * list[i].grade);
* * * ** **** * ** ** * *** ** * * ** ** **
* ** * ***** * * *** * * ***


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

}
最新回答 用戶: (-188 分)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.253.42
©2016-2025

相關問題

0 喜歡 0 不喜歡
6 回答
[正常] 最新提問 4月 21, 2017 分類:Midterm | 用戶: thopd (12.1k 分)
ID: 24271 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.2k 瀏覽
0 喜歡 0 不喜歡
13 回答
[考試] 最新提問 4月 21, 2017 分類:Midterm |
ID: 24269 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2k 瀏覽
0 喜歡 0 不喜歡
70 回答
[考試] 最新提問 4月 13, 2017 分類:Midterm |
ID: 23789 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 7.7k 瀏覽
0 喜歡 0 不喜歡
4 回答
[考試] 最新提問 4月 21, 2017 分類:Midterm |
ID: 24272 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1k 瀏覽
0 喜歡 0 不喜歡
11 回答
[考試] 最新提問 4月 21, 2017 分類:Midterm |
ID: 24270 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶