hdu 2550 百步穿杨(大水题)

来源:互联网 发布:数据交换的方式 编辑:程序博客网 时间:2024/04/29 06:42

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2550

又是大水题。。。杭电果然名不虚传。。。

不过我还是跟着E.star大神的脚步走上去吧。。。

#include<cstdio>#include<algorithm>#define MAXN 35using namespace std;struct S{int n, l;};bool cmp(S a, S b){return a.l < b.l;}int main(){int t, n;S s[MAXN];scanf("%d", &t);while (t--){scanf("%d", &n);for (int i = 0; i < n; i++)scanf("%d%d", &s[i].l, &s[i].n);sort(s, s+n, cmp);for (int i = 0; i < n; i++){for (int k = 0; k < s[i].n; k++){printf(">+");for (int j = 0; j < s[i].l - 2; j++)printf("-");printf("+>\n");}printf("\n");}}return 0;}


原创粉丝点击