KIDx's Pagination
来源:互联网 发布:淘宝在ipad上无法横屏 编辑:程序博客网 时间:2024/06/01 19:40
KIDx's Pagination
Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)
Submit Statistic Next Problem
Problem Description
One Day, KIDx developed a beautiful pagination for ACdream. Now, KIDx wants you to make another one.
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.
Input
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.
Output
For each test case, output one line containing "Case #x: " followed by the result of pagination.
Sample Input
10 5 210 1 2
Sample Output
Case #1: (<<)[...](3)(4)[5](6)(7)[...](>>)Case #2: [<<][1](2)(3)[...](>>)
Hint
Case 1:
Case 2:
Source
KIDx
Manager
KIDx
///这是一道简单的模拟题,可我>_<||
#include<stdio.h>#include<string.h>#include<math.h>int main(){ int n, cur, d, num=0; while(~scanf("%d%d%d", &n, &cur, &d)) { num++; printf("Case #%d: ", num); if(cur==1) printf("[<<]"); else printf("(<<)"); if(cur-d>1) printf("[...]"); for(int i=1;i<=n;i++) { if(i==cur) printf("[%d]", cur); else if(fabs(cur-i)<=d) printf("(%d)", i); } if(cur+d<n) printf("[...]"); if(cur==n) printf("[>>]"); else printf("(>>)"); puts(""); } return 0;
}
0 0
- 周赛-KIDx's Pagination
- KIDx's Pagination
- ACdream 1196 KIDx's Pagination
- ACdream 1196 KIDx's Pagination(模拟)
- A -KIDx's Pagination(练功底)
- KIDx's Pagination (周赛1)
- ACdream 1196 KIDx's Pagination(模拟)
- Acdream 1203 KIDx's Triangle(解三角形)
- ACdream 1203 - KIDx's Triangle(解题报告)
- Pagination
- PAGINATION
- Pagination
- angular-bootstrap-ui's pagination ng-change 事件在页面加载时会执行两次
- Pagination Tag
- Hibernate pagination
- easyUI Pagination
- eXtremeDB pagination
- jquery-pagination
- Java:面向未来的七大强力新特性
- Linux常用命令(三)
- Google Android SDK开发范例大全目录
- C++之多态性与虚函数
- owncloud源码分析1--部分修改Demo
- KIDx's Pagination
- UVALive 5809 Binary Matrix
- 【Linux使用笔记】
- 让文本框和按钮在同一水平线上
- 回调函数的作用
- 八大排序算法
- poj-1458-Common Subsequence
- L2TP连接尝试失败,因为安全层在初始化与远程计算机的协商时遇到了一个处理错误
- Android多媒体系统分析-Handler, MessageQueue, Runnable与Looper概念