Title: http://acm.gdufe.edu.cn/Problem/read/id/1033
Making arrows? Time limit:2000/1000ms (java/others) problem Description:
The annual GDCC School sports meeting is about to be grandly opened! This year has added an archery contest, so cool ~ you want to participate, but the organizing committee does not provide the bow and arrow ╯﹏╰ that had to be the contestants themselves. Now to forge the bows, including the length of the arrow, the number of arrows required for different lengths of N, requires you to export the required arrows. The basic shape of the bow is ">+---+>", where "+---+" is the arrow body, the data guarantee the length of the Arrows > 2. All right, 工欲善其事 its prerequisite, make arrows!!
Input:
First enter a number T, indicating that there is a T group of data, each group of data has a M (m<50), followed by M-line, the first line of two integer l,n, respectively, the arrow body length of the arrows have N, (l<, n< 10) input data to ensure that each l>2 and are different
Output:
According to the length of the arrow body from small to large in order to output all the required arrows, each type of bow and arrow behind a blank line.
Sample Input:
132 38 24 5
Sample Output:
>++>>++>>++>>+--+>>+--+>>+--+>>+--+>>+--+>>+------+>> +------+>
Idea: Sort first, then output >+, then output L-2-, then output +> loop n times
Difficulty: Look at the thought is simple ...
Code:
1#include <stdio.h>2 intMain ()3 {4 intt,l[ -],n[ -],a,b,c,i,j,k;5 while(~SCANF ("%d",&t))6 {7 while(t--)8 {9scanf"%d",&k);Tenscanf"%d%d", &l[0],&n[0]); One for(i=1; i<k;i++) A { -scanf"%d%d",&l[i],&n[i]); - for(j=i;j>0; j--) the{if(l[j]>l[j-1]) Break; -a=l[j];l[j]=l[j-1];l[j-1]=A; -a=n[j];n[j]=n[j-1];n[j-1]=A;} - } + for(i=0; i<k;i++) - { + for(j=0; j<n[i];j++) A { atprintf">+"); - for(c=2; c<l[i];c++) -printf"-"); -printf"+>\n"); - } -printf"\ n"); in } - } to } + return 0; -}
Gdufe ACM-1033