我有一本书中的这个示例程序,在这段代码中有一行
++frequency[responses[RESPOSE_SIZE]];
. 我无法理解我们如何增加数组基地址?我可能是个傻瓜吗?但我仍然没有看到任何逻辑......请有人帮助我......谢谢!
int main()
{
int answer, rating;
int frequency[FREQUENCY_SIZE] = {5};
int responses[RESPOSE_SIZE] ={1,2,3,4,5,6,7,8,9,10,
1,6,3,8,6,10,3,8,2,7,6,5,7,6,8,6,7,5,6,6,
5,6,7,5,6,4,8,6,8,10};
for(answer = 0; answer<RESPOSE_SIZE; answer++)
{
++frequency[responses[RESPOSE_SIZE]];
}
printf( "%s%17s\n", "Rating", "Frequency" );
for(rating=1; rating<FREQUENCY_SIZE; rating++)
{
printf( "%6d%17d\n", rating, frequency[ rating ] );
}
return 0;
}