息止


私信TA

用户名:2194669092

访问量:976

签 名:

等  级
排  名 11428
经  验 970
参赛次数 0
文章发表 14
年  龄 0
在职情况 学生
学  校 南昌工程学院
专  业

  自我简介:

TA的其他文章

解题思路:也可以用set,用完begin后erase,就可以使用下一个

注意事项:可能多组数据,注意恢复变量初始值

参考代码:

#include<cstdio>

#include<iostream>

#include<algorithm>

using namespace std;

struct h

{

int x;

int y;

};

bool cmp(h a,h b)

{    

return a.x<b.x;

}

int main()

{

int n,j,i=0,k=0,p=0,x,y;

cin>>n;

h s[100];

while(n--)

{

cin>>j;

for(i=0;i<j;i++)

{

cin>>x>>y;

s[i].x=x;

s[i].y=y;

}

sort(s,s+j,cmp);

p=0;//注意恢复变量初始值

while(j--)

{

for(i=0;i<s[p].y;i++)

{

cout<<">+";

for(k=2;k<s[p].x;k++)

cout<<"-";

cout<<"+>";

cout<<endl;

}

cout<<endl;

p++;

}

}

return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区