ACdream 1196 KIDx's Pagination
来源:互联网 发布:mac机ae cc2014序列号 编辑:程序博客网 时间:2024/06/07 09:06
The are n pages in total.
The current page is cur.
The max distance to current page you can display is d.
Here are some rules:
- The cur page button is disabled.
- If cur page is the first page, the button "<<" should be disabled.
- If cur page is the last page, the button ">>" should be disabled.
- If the button "x" is disabled, print "[x]"; else print "(x)".
- You should not display the "..." button when there is no hidden page.
You can assume that the button "..." is always disabled.
There are multiple cases.
Ease case contains three integers n, cur, d.
1 ≤ n ≤ 100.
1 ≤ cur ≤ n.
0 ≤ d ≤ n.
Ease case contains three integers n, cur, d.
1 ≤ n ≤ 100.
1 ≤ cur ≤ n.
0 ≤ d ≤ n.
For each test case, output one line containing "Case #x: " followed by the result of pagination.
10 5 210 1 2
Case #1: (<<)[...](3)(4)[5](6)(7)[...](>>)Case #2: [<<][1](2)(3)[...](>>)
Case 1:
Case 2:
原题链接:KIDx's Pagination
认真看题的话,这题不难,挺循规蹈矩的!
来看代码:
#include <iostream>#include <cstdio> using namespace std; int main(){ int n,cur,d,tp,cnt = 0; int i; while(scanf("%d %d %d",&n,&cur,&d)!=EOF) { printf("Case #%d: ",++cnt); if(cur != 1) printf("(<<)"); else printf("[<<]"); if(cur - d > 1) printf("[...]"); if(cur - d < 1) tp = 1; else tp = cur - d; for(i = tp; i < cur && i >= 1; i++) printf("(%d)",i); printf("[%d]",cur); //以cur为分水岭 for(i = cur + 1; i <= cur + d && i <= n; i++) printf("(%d)",i); if(cur + d < n) printf("[...]"); if(cur != n) printf("(>>)"); else printf("[>>]"); puts(""); //这条语句等价于printf("\n");或者cout>>endl; } return 0;}
题不难,代码也不难理解,只要认真耐心看完就能懂哦! 1 0
- ACdream 1196 KIDx's Pagination
- ACdream 1196 KIDx's Pagination(模拟)
- ACdream 1196 KIDx's Pagination(模拟)
- 周赛-KIDx's Pagination
- KIDx's Pagination
- A -KIDx's Pagination(练功底)
- KIDx's Pagination (周赛1)
- Acdream 1203 KIDx's Triangle(解三角形)
- ACdream 1203 - KIDx's Triangle(解题报告)
- Pagination
- PAGINATION
- Pagination
- 【ACdream】ACdream原创群赛(18)のAK's dream
- acdream 1201 SuSu's Power dp
- ACdream Andrew Stankevich's Contest(1)
- ACdream Andrew Stankevich's Contest(1)
- ACdream Andrew Stankevich's Contest (2) 哈夫曼树
- 【ACdream】Andrew Stankevich's Contest (22)
- 数据结构实验之查找二:平衡二叉树
- 1613-3-傅溥衍 总结《2016年12月10日》【连续第七十一天总结】
- 深浅拷贝
- BZOJ 2563 阿狸和桃子的游戏
- 【35.29%】【codeforces 557C】Arthur and Table
- ACdream 1196 KIDx's Pagination
- 使用clang进行交叉编译
- Ant 打包 SSH框架
- QT开发之TCP协议
- 通过ip区分内网和外网
- hibernate总结一
- UIP移植到CC2530上
- 单片机学习第一章
- 拷贝构造和赋值构造