// ex5-20.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
const int citys=5;
const int year=4;
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std;
const char * city[citys]=
{
"Beijing",
"Shanghai",
"Nanjing",
"Tianjin",
"Aomen "
};
int maxtemps[year][citys]=
{
{33,24,23,14,15},
{34,5,234,5,34},
{34,5,34,65,42},
{12,23,4,31,12}
};
cout<<"max temps\n\n";
for (int i=0;i<citys;++i)
{
cout<<city[i]<<":\t";
for (int j=0;j<year;++j)
{
cout<<maxtemps[j][i]<<'\t';
}
cout<<endl;
}
system("pause");
return 0;
}
使用for()嵌套循环输出二维数组
最新推荐文章于 2023-05-17 21:43:34 发布