

注解
1、本题是模拟书籍的装订,输出每一页用纸所对应的书籍页码。
2、每一页纸可细分为正面和反面,正面又包含两页,反面也包含两页。
3、需要注意的情况是Blank,也就是不包含的页码。
代码
#include <iostream>
#include <cmath>
using namespace std;
int n;
void process() {
cout<<"Printing order for "<<n<<" pages:"<<endl;
int page = ceil(n/4.0);
for(int i=1; i<=page; i++) {
int maxpage = page*4-(i-1)*2;
cout<<"Sheet "<<i;
if(n<maxpage) {
cout<<", front: Blank, "<<(i*2-1)<<endl;
} else {
cout<<", front: "<<maxpage<<", "<<(i*2-1)<<endl;
}
if(i*2<=n) {
cout<<"Sheet "<<i<<", back : ";
if(n<maxpage-1) {
cout<<(i*2)<<", Blank"<<endl;
} else {
cout<<(i*2)<<", "<<(maxpage-1)<<endl;
}
}
}
}
int main() {
cin>>n;
while(n) {
process();
cin>>n;
}
return 0;
}
结果

最后
以上就是闪闪鸡最近收集整理的关于【简单模拟】HDU-1117 Booklet Printing注解代码结果的全部内容,更多相关【简单模拟】HDU-1117内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复