UVA 488 10038 10107 10370
2015-03-02 21:05
351 查看
488:
Triangle Wave
Submit Status
Description
In this problem you are to generate a triangular wave form according to a specified pair of Amplitude and Frequency.
line between two consecutive inputs.
Each input set will contain two integers, each on a separate line. The first integer is the Amplitude; the second integer is the Frequency.
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
For the output of your program, you will be printing wave forms each separated by a blank line. The total number of wave forms equals the Frequency, and the horizontal ``height'' of each wave equals the Amplitude.
The Amplitude will never be greater than nine.
The waveform itself should be filled with integers on each line which indicate the ``height'' of that line.
NOTE: There is a blank line after each separate waveform, excluding the last one.
解题思路:
这道题完全是看算法笔记的时候,照着他的例题刷的,没有什么技巧,就是在打印空行上面,WA了好几次。。。
代码:
解题思路:
代码:
Triangle Wave
Time Limit: 3000MS | Memory Limit: Unknown | 64bit IO Format: %lld & %llu |
Description
Triangle Wave |
Input and Output
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blankline between two consecutive inputs.
Each input set will contain two integers, each on a separate line. The first integer is the Amplitude; the second integer is the Frequency.
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
For the output of your program, you will be printing wave forms each separated by a blank line. The total number of wave forms equals the Frequency, and the horizontal ``height'' of each wave equals the Amplitude.
The Amplitude will never be greater than nine.
The waveform itself should be filled with integers on each line which indicate the ``height'' of that line.
NOTE: There is a blank line after each separate waveform, excluding the last one.
Sample Input
1 3 2
Sample Output
1 22 333 22 1 1 22 333 22 1
解题思路:
这道题完全是看算法笔记的时候,照着他的例题刷的,没有什么技巧,就是在打印空行上面,WA了好几次。。。
代码:
# include<cstdio> int main(void) { int N; scanf("%d", &N); for(int i=0; i<N; i++) { int A, F; scanf("%d%d", &A, &F); for(int k1=0; k1<F; k1++) { for(int k2=1; k2<=A; k2++) { for(int k3=1; k3<=k2; k3++) printf("%d", k2); printf("\n"); } for(int k4=A-1; k4>=1; k4--) { for(int k5=1;k5<=k4;k5++) printf("%d", k4); printf("\n"); } if(k1!=F-1) printf("\n"); } if(i != N-1) printf("\n"); } return 0; }10038:
解题思路:
代码:
相关文章推荐
- UVA 488 - Triangle Wave
- UVa10038:Jolly Jumpers
- POJ2575 ZOJ1879 UVA10038 Jolly Jumpers【序列】
- UVa 488 三角波
- UVa - 10038 - Jolly Jumpers
- UVA 488-Triangle Wave
- uva 488
- uva-488 三角波
- UVA488,振幅频率输出数
- UVa 10370 - Above Average
- UVA 10038 - Jolly Jumpers
- uva488 Triangle Wave
- uva 10107 - What is the Median?
- uva-10038- Jolly Jumper
- UVa 10038 Jolly Jumpers
- UVA 10038
- UVa488 - Triangle Wave
- UVa_488 - Triangle Wave
- uva488 Triangle Wave
- uva 488 triangle wave