solution.md 2.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
# 成绩统计
#### 问题描述
编写一个程序,建立了一条单向链表,每个结点包含姓名、学号、英语成绩、数学成绩和C++成绩,并通过链表操作平均最高的学生和平均分最低的学生并且输出。  
#### 输入格式
输入n+1行,第一行输入一个正整数n,表示学生数量;接下来的n行每行输入5个数据,分别表示姓名、学号、英语成绩、数学成绩和C++成绩。注意成绩有可能会有小数。  
#### 输出格式
输出两行,第一行输出平均成绩最高的学生姓名。第二行输出平均成绩最低的学生姓名。  
#### 样例输入
```
2
yx1 1 45 67 87
yx2 2 88 90 99
```
#### 样例输出
```
yx2
yx1
```

## aop
### before
```cpp
#include <iostream>
using namespace std;
```
### after
```cpp

```

## 答案
```cpp
int main()
{
	struct student
	{
		string xm;
		int xh;
		double yy;
		double sx;
		double cpp;
	};
	student a[1000];
	int n;
	double sum = 0, min = 301, max = 0;
	string mins, maxs;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].xm >> a[i].xh >> a[i].yy >> a[i].sx >> a[i].cpp;
		sum = a[i].yy + a[i].sx + a[i].cpp;
		if (min > sum)
		{
			min = sum;
			mins = a[i].xm;
		}
		if (max < sum)
		{
			max = sum;
			maxs = a[i].xm;
		}
	}
	cout << maxs << endl
		 << mins;
	return 0;
}

```
## 选项

### A
```cpp
int main()
{
	struct student
	{
		string xm;
		int xh;
		double yy;
		double sx;
		double cpp;
	};
	student a[1000];
	int n;
	double sum = 0, min = 301, max = 0;
	string mins, maxs;
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> a[i].xm >> a[i].xh >> a[i].yy >> a[i].sx >> a[i].cpp;
		sum = a[i].yy + a[i].sx + a[i].cpp;
		if (min > sum)
		{
			min = sum;
			mins = a[i].xm;
		}
		if (max < sum)
		{
			max = sum;
			maxs = a[i].xm;
		}
	}
	cout << maxs << endl
		 << mins;
	return 0;
}
```

### B
```cpp
int main()
{
	struct student
	{
		string xm;
		int xh;
		double yy;
		double sx;
		double cpp;
	};
	student a[1000];
	int n;
	double sum = 0, min = 301, max = 0;
	string mins, maxs;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].xm >> a[i].xh >> a[i].yy >> a[i].sx >> a[i].cpp;
		sum = a[i].yy + a[i].sx + a[i].cpp;
		if (min > sum)
		{
			min = sum;
			mins = a[i]->xm;
		}
		if (max < sum)
		{
			max = sum;
			maxs = a[i]->xm;
		}
		cout << maxs << endl
			 << mins;
		return 0;
	}
}
```

### C
```cpp
int main()
{
	struct student
	{
		string xm;
		int xh;
		double yy;
		double sx;
		double cpp;
	};
	student a[1000];
	int n;
	double sum = 0, min = 301, max = 0;
	string mins, maxs;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].xm >> a[i].xh >> a[i].yy >> a[i].sx >> a[i].cpp;
		sum = a[i].yy + a[i].sx + a[i].cpp;
		if (min > sum)
		{
			min = sum;
			mins = a[i].xm;
		}
		if (max < sum)
		{
			max = sum;
			maxs = a[i].xm;
		}
	}
	cout << mins << endl
		 << maxs;
	return 0;
}
```