当前位置: > What does the following example do?...
题目
What does the following example do?
void send(int* to,int* from,int count)
{
int n=(count+7)%8;
switch(count%8)
{
case 0: do { *to++ = *from++;
case 7: *to++ = *from++;
case 6: *to++ = *from++;
case 5: *to++ = *from++;
case 4: *to++ = *from++;
case 3: *to++ = *from++;
case 2: *to++ = *from++;
case 1: *to++ = *from++;
}while(--n>0);
}
}
//The C++ Programming Language (Third Edition) CH6 - 15

提问时间:2021-03-25

答案
主要目的是把从from开始拷贝数据到to.
拷贝数量是 ( ( ( count + 7 ) % 8 ) - 1 ) * 8 + ( count % 8 ) 个元素.
第一次从count%8开始,依次执行 case count%8-1,case count%8-2 ..到
case 1,
然后循环n-1次,执行 do {} 中间的代码.
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.