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 2 10 1 2
Sample Output
Case #1: (<<)[...](3)(4)[5](6)(7)[...](>>) Case #2: [<<][1](2)(3)[...](>>)
#include <stdio.h>
#include <math.h>
int main()
{
int n,c,d;
int count=0;
while(~scanf("%d %d %d",&n,&c,&d))
{
int i,x;
count++;
printf("Case #%d: ",count);
if(c==1)
printf("[<<]");
else
printf("(<<)");
if(c-d>1)
{
printf("[...]");
x=c-d;
}
else
x=1;
for(i=x;i<c;i++)
printf("(%d)",i);
printf("[%d]",c);
if(c+d<n)
x=c+d;
else
x=n;
for(i=c+1;i<=x;i++)
printf("(%d)",i);
if(c+d<n)
printf("[...]");
if(c==n)
printf("[>>]");
else
printf("(>>)");
printf("\n");
}
return 0;
}
本文详细解读了页面布局的开发过程,并提供了一种优化方法来实现更流畅的用户体验。通过实例分析,展示了如何根据特定规则调整按钮显示,确保导航逻辑清晰且直观。
213

被折叠的 条评论
为什么被折叠?



