从一个三行四列的二维数组中查找最大元素数据。
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库#include <iostream>
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库using namespace std;
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库int main()
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库const int rows = 3; //数组行数
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库const int columns = 4; //数组行数
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库float highest = 0; //求二维数组的最大元素
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库float Temp[rows][columns] = {{26.1, 34.6, 22.6, 17.8},
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{24.5, 32.1, 19.8, 13.5},
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{28.6, 38.2, 25.6, 20.8},
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}; //初始化
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库for (int i = 0; i < rows; ++i)
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库for (int j = 0; j < columns; ++j)
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库if (Temp[i][j] > highest)
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库highest = Temp[i][j];
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库cout << "最大元素为:" << highest << endl;
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库return 0;
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库程序运行结果:
oem100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库最大元素为:38.2