C++学习第三十一篇

/*
* 二维数组案例-考试成绩统计
*/
#include<iostream>
#include<string>
using namespace std;
int main()
{
	//1、创建二维数组
	int scores[3][3] =
	{
		{100,100,100},
		{90,50,100},
		{60,70,80}
	};
	string names[3] = { "张三","李四","王五" };
	//统计每个人都总和分数
	for (int i = 0; i < 3; i++)
	{
		int sum = 0;
		for (int j = 0;j < 3;j++)
		{
			sum += scores[i][j];
		}
		cout << names[i] << "的总分:  " << sum << endl;
	};
	system("pause");
	return 0;
}

			    

猜你喜欢

转载自blog.csdn.net/weixin_47358937/article/details/121462014