UVa488 Triangle Wave
来源:互联网 发布:杭州淘宝拍摄基地tnt 编辑:程序博客网 时间:2024/06/16 02:12
In this problem you are to generate a triangular wave form according to a specified pair ofAmplitude and Frequency.
Input and Output
The input begins with a single positive integer on a line by itself indicatingthe number of the cases following, each of them as described below. This line isfollowed by a blank line, and there is also a blank line between two consecutiveinputs.
Each input set will contain two integers, each on a separate line. The first integer is the Amplitude; thesecond integer is the Frequency.
For each test case, the output must follow the description below. The outputs oftwo 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 waveequals 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 thatline.
NOTE: There is a blank line after each separate waveform, excluding the last one.
Sample Input
132
Sample Output
122333221122333221
这题大意就是按照给定的格式(如样例)输出,要注意的只有空行了,在每个样例之间及在每个三角波之间都要有个空行,其他不能有空行。
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>#include <cctype>using namespace std;int main() {int Case;cin >> Case;while (Case--) {int a;int b;cin >> a >> b;while (b--) {for (int i = 1; i <= a; i++) {for (int j = 1; j <= i; j++) {cout << i;}cout << endl;}for (int i = a-1; i > 0; i--) {for (int j = i; j > 0; j--) {cout << i;}cout << endl;}if (b)cout << endl;}if (Case)cout << endl;}return 0;}
- uva488 Triangle Wave
- UVa488 Triangle Wave
- Uva488 Triangle Wave
- UVa488 - Triangle Wave
- UVA488 Triangle Wave
- UVA488 - Triangle Wave
- UVa488 - Triangle Wave-难度1
- 算法竞赛入门经典-前四章-UVa488 - Triangle Wave-三角波-难度1
- Triangle Wave
- Triangle Wave
- Triangle Wave
- Triangle Wave
- Triangle Wave
- uva488
- uvaoj 488 - Triangle Wave
- UVa 488 Triangle Wave
- Uva 488 Triangle Wave
- UVa Triangle Wave
- 7月国内智能终端浏览器市场:安卓自带浏览器第一
- Linux的bg和fg命令
- sdsadasdsad
- 浏览器大战7月赛果:Chrome还在进步,Firefox下滑
- tomcat不能同时运行两个项目问题解决方案。
- UVa488 Triangle Wave
- 学习python(十一)
- COM原理笔记之一 —— 概述篇
- SQL Server,Access数据库查询易混点和C#中parameter指定参数长度的优缺点
- Socket模型详解(转)
- c++实现链表倒序
- hdu 3351
- org.apache.jasper.JasperException
- 嵌入式驱动开发的前期Linux 和 C学习(五)