码迷,mamicode.com
首页 > 其他好文 > 详细

模拟 ACdream 1196 KIDx's Pagination

时间:2015-04-10 22:20:20      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

 

题目传送门

 1 /*
 2     简单模拟;考虑边界的情况输出的是不一样的,还有思维好,代码能短很多
 3 */
 4 #include <cstdio>
 5 #include <iostream>
 6 #include <algorithm>
 7 #include <string>
 8 #include <cstring>
 9 #include <map>
10 #include <vector>
11 using namespace std;
12 
13 const int MAXN = 1e4 + 10;
14 const int INF = 0x3f3f3f3f;
15 
16 int main(void)        //ACdream 1196 KIDx‘s Pagination
17 {
18     //freopen ("A.in", "r", stdin);
19 
20     int n, cur, d;
21     int a[110];
22     int cas = 0;
23     while (scanf ("%d%d%d", &n, &cur, &d) == 3)
24     {
25         printf ("Case #%d: ", ++cas);
26         if (cur == 1)    printf ("[<<]");
27         else    printf ("(<<)");
28 
29         if (cur - d > 1)    printf ("[...]");
30         for (int i=max(cur-d, 1); i<cur; ++i)    printf ("(%d)", i);
31         printf ("[%d]", cur);
32         for (int i=cur+1; i<=min(cur+d, n); ++i)    printf ("(%d)", i);
33         if (cur + d < n)    printf ("[...]");
34 
35         if (cur == n)    printf ("[>>]");
36         else printf ("(>>)");
37         puts ("");
38     }
39 
40     return 0;
41 }
42 
43 /*
44 Case #1: (<<)[...](3)(4)[5](6)(7)[...](>>)
45 Case #2: [<<][1](2)(3)[...](>>)
46 */

 

模拟 ACdream 1196 KIDx's Pagination

标签:

原文地址:http://www.cnblogs.com/Running-Time/p/4415721.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!