c++语句问题

来源:百度知道 编辑:UC知道 时间:2024/05/27 23:51:17
#include<iostream.h>
const char * books[]={"chinese","maths","history","geography"};
const int money[4]={21,44,17,52};
void main()
{
int index,eee=0;
for(int i=0;i<4;i++)
{
if(eee<money[i])
{
eee=money[i];
index=i;
}
}
cout<<books[index]<<endl;
}
这个代码我想来想去都不知道为什么会显示出最大的书名,请大家帮我注释下!!

#include<iostream.h>
const char * books[]={"chinese","maths","history","geography"};
const int money[4]={21,44,17,52}; //定义数组
void main()
{
int index,eee=0; //初始化
for(int i=0;i<4;i++)
{
if(eee<money[i]) //选出最大的那个数
{
eee=money[i];
index=i;
}
}
cout<<books[index]<<endl; //输出最大数对应的单词
}