第一代:
#include<iostream>
using namespace std;
int main()
{
int arr[3][3] = {
{100,100,100},
{90,50,100},
{60,70,80}
};
for (int i = 0; i < 3; i++)
{
switch(i)
{
case 0:
cout << "张三的总分为:" << arr[i][0] + arr[i][1] + arr[i][2] << endl;
break;
case 1:
cout << "李四的总分为:" << arr[i][0] + arr[i][1] + arr[i][2] << endl;
break;
case 2:
cout << "王五的总分为:" << arr[i][0] + arr[i][1] + arr[i][2] << endl;
break;
}
}
system("pause");
return 0;
}
第二代:
#include<iostream>
using namespace std;
int main()
{
int arr[3][3] = {
{100,100,100},
{90,50,100},
{60,70,80}
};
for (int i = 0; i < 3; i++)
{
int sum = 0;
for (int j = 0; j < 3; j++)
{ //for 循环和 sum+= 是常见的累加操作,每一次循环