模拟 URAL 1149 Sinus Dances

 

题目传送门

 1 /*
 2     模拟:找到规律分别输出就可以了,简单但是蛮有意思的
 3 */
 4 #include <cstdio>
 5 #include <algorithm>
 6 #include <cstring>
 7 #include <cmath>
 8 #include <string>
 9 using namespace std;
10 
11 const int MAXN = 2e2 + 10;
12 const int INF = 0x3f3f3f3f;
13 
14 void print_An(int n)
15 {
16     for (int i=1; i<=n; ++i)
17     {
18         printf ("sin(%d", i);
19         if (i < n)    printf ("%c", (i&1) ? '-' : '+');
20     }
21 
22     for (int i=1; i<=n; ++i)    printf ("%c", ')');
23 }
24 
25 void work(int n)
26 {
27     for (int i=1; i<n; ++i)    printf ("%c", '(');
28     print_An (1);    printf ("%c%d", '+', n);
29     for (int i=n-1, j=1; i>=1; --i)
30     {
31         printf ("%c", ')');    print_An (++j);
32         printf ("%c%d", '+', i);
33     }
34     puts ("");
35 }
36 
37 int main(void)        //URAL 1149    Sinus Dances
38 {
39     // freopen ("F.in", "r", stdin);
40 
41     int n;
42     while (scanf ("%d", &n) == 1)
43     {
44         work (n);
45     }
46 
47     return 0;
48 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4644766.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值