|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <iostream>
- using namespace std;
- const int cities = 4;
- const int years =5 ;
- int main()
- {
- const char *cities[cities]=
- {
- "Gribble city",
- "Gribbletown",
- "New Gribble",
- "San Gribble",
- "Gribble vista"
- };
- int maxtemps[years][cities]=
- {
- {96,100,87,101,105},
- {97,101,88,102,106},
- {98,102,89,103,107},
- {99,103,90,104,108}
- };
- cout<<"Maximum teperatures for 2008 - 2011\n\n";
- for(int city = 0; city<cities;++city)
- {
- cout<< cities[city];
- for(int year=0;year<years;++year)
- cout<<maxtemps[year][city];
- cout<<endl;
- }
- return 0;
- }
复制代码 各位大婶们,小弟初学C++,现在看的书是C++ primer plus,现在看到第五章的二维数组,编译器是CodeBlocks,以上代码为何不能通过编译? 照着书上打上去的,跟着书的思路分析的,为何错误呢? 二维数组不能直接赋值和访问成员的吗? 错误原因请看截图,刚才发错板块了。。。
|
|