5.3.3、二维数组案例-考试成绩统计

代码

cpp 复制代码
#include <iostream>
using namespace std;
#include <string>

int main()
{

	//二维数组案例-考试成绩统计

	//1、创建二维数组
	int scores[3][3] =
	{
		{100,100,100},
		{90,50,100},
		{60,70,80},
	};

	string names[3] = { "张三","李四","王五" };
	//2、统计每个人的分数总和
	for (int i = 0; i < 3; i++)
	{
		int sum = 0;
		for (int j = 0; j < 3; j++)
		{
			sum += scores[i][j];
			/*cout << scores[i][j] << " ";*/
		}
		cout << names[i]<<"个人的总分为:"<<sum<< endl;
	}


	system("pause");

	return 0;
}
相关推荐
Ada's4 小时前
【计算机基础系列】003:Python数据结构
开发语言·数据结构·python
Nil2085 小时前
leetcode 118杨辉三角
算法·leetcode·职场和发展
NeilYuen7 小时前
【C++】STL源码仿写(二):vector
开发语言·c++
郝学胜_神的一滴7 小时前
游戏引擎原理与实践 04:拆解引擎基础系统与内存管理
c++·游戏
wanderist.7 小时前
线性筛法详解:从筛质数到欧拉函数、Möbius 函数与约数函数
java·数据结构·算法
All for pursuit.8 小时前
【设计-1】208.实现Trie (前缀树)
数据结构·c++·算法·leetcode
weixin_307779138 小时前
C++代码实现MATLAB中的crossval函数功能
开发语言·c++·算法·matlab
青少儿编程课堂8 小时前
背包问题(0/1 背包与完全背包)解题精讲——动态规划入门
c++·python·算法·bfs·信息学竞赛
倒头就睡的小比特8 小时前
C++多态
c++
光影少年9 小时前
为什么 JavaScript 中 0.1 + 0.2 !== 0.3,如何让其相等?
前端·javascript·算法