- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main(void){
- cout<<"感謝各位的協助"<<endl;
- srand(time(NULL));
- int stu_num;
- int max[2];
- max[1] = 0;
- int min[2];
- min[1] = 100;
- cout << "**請輸入學生人數**" << endl;
- cin >> stu_num;
- int jj[stu_num][5];
-
- for(int i = 0; i < stu_num; i++){
- jj[i][0] = i + 1;
- jj[i][1] = 1 + rand()%100;
- jj[i][2] = 1 + rand()%100;
- jj[i][3] = 1 + rand()%100;
- jj[i][4] = (jj[i][1]+jj[i][2]+jj[i][3]) / 3;
- if(jj[i][4] > max[1]){
- max[0] = i + 1;
- max[1] = jj[i][4];
- }else if(jj[i][4] < min[1]){
- min[0] = i + 1;
- min[1] =jj[i][4];
- }
- }
-
- cout << "!!!"<<max[0] << "號的平均值最大!!!1,~平均值為" << max[1] <<"~"<< endl;
- cout <<"!!!"<< min[0] << "號的平均值最小,平均值為" << min[1] <<"~"<< endl;
-
- system("pause");
- return 0;
- }
複製代碼 |