实现效果和想象中的不一致,求大神指点【二维数组+for嵌套循环】
											 程序代码:
程序代码:
#include <iostream>
using namespace std;
const int Cities = 5; 
const int Years = 4;
int main()
{
    const char * cities[Cities] = // array of pointers 
    {                              // to 5 strings
        "Gribble City",
        "Gribbletown",
        "New Gribble",
        "Gribble vista"
    };
    int maxtemps[Years][Cities] = // 2-D array 
    {
        {96, 100, 87, 101, 105}, // values for maxtemps[0]
        {96, 98, 91, 107, 104}, // values for maxtemps[1]
        {97, 101, 93, 108, 107}, // values for maxtemps[2]
        {98, 103, 95, 109, 108} // values for maxtemps[3]
    };
    
    cout << "Maximum temperatures for 2008 - 2011\n\n";
    for (int city = 0; city < Cities; ++city)
    {
        cout << cities[city] << ":\t";
        for (int year = 0; year < Years; ++year)
            cout << maxtemps[year][city] << "\t";
        cout << endl;
    }
        // cin.get();
    return 0;
}
想象中的实现效果:
Maximum temperatures for 2008 - 2011
Gribble City:96
Gribbletown: 98
New Gribble: 93
Gribble vista:109
. . .
(省略的大神们应该能知道我想的是什么吧!)
Gribble City:96
Gribbletown: 98
New Gribble: 93
Gribble vista:109
. . .
(省略的大神们应该能知道我想的是什么吧!)
现实中的实现效果:
Maximum temperatures for 2008 - 2011
Gribble City: 96 100 87 101 105
Gribbletown: 96 98 91 107 104
New Gribble: 97 101 93 108 107
Gribble vista:98 103 95 109 108
Gribble City: 96 100 87 101 105
Gribbletown: 96 98 91 107 104
New Gribble: 97 101 93 108 107
Gribble vista:98 103 95 109 108
(实现效果是很整齐的噢)
求大神指点一下为什么实现效果是这样!
感谢!!!
[此贴子已经被作者于2018-12-31 20:48编辑过]



 
											





 
	    

 
	
 
											




