博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
488 - Triangle Wave
阅读量:5162 次
发布时间:2019-06-13

本文共 2478 字,大约阅读时间需要 8 分钟。

In this problem you are to generate a triangular wave form according to a specified pair of Amplitude and Frequency.

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 blank 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.

在这个问题中,根据所给的振幅(Amplitude)及频率(Frequency),你的程式要产生这样的波。

Input
输入的第一列有一个整数n,代表有几组测试资料。接下来每组测试资料有2列,各有1个正整数(A、F),A代表振幅(A<=9),F代表频率。
第一列以及各组测试资料间皆有一空白行。请参考Sample input。
Output
每组测试资料请输出F个波,每个波振幅的水平高度为A。波本身是以其"高度"的内容所组成。每个波之间以一空白行分隔开来。
测试资料间也以一空白行分开。

Sample Input

132

Sample Output

122333221122333221

解题思路:唯一要注意的是两组数据之间的空行和数据内部的空行是不同的

#include
int main(){
int n,a,f,i,j,t,b;scanf("%d",&n);while(n--){ scanf("%d%d",&a,&f); if(a==0&&f==0)break; for(i=0;i
a){ t=a-(j-a); b=t; } else { t=j; b=t; } while(t--) printf("%d",b); printf("\n"); } if(i!=f-1)printf("\n"); } if(n!=0)printf("\n"); }return 0; }

 

转载于:https://www.cnblogs.com/EVA00/archive/2013/02/06/2901817.html

你可能感兴趣的文章
vue实例中中data属性三种写法
查看>>
uva1636 - Headshot(条件概率)
查看>>
iOS开发 runtime实现原理以及实际开发中的应用
查看>>
BZOJ2437 NOI2011兔兔与蛋蛋(二分图匹配+博弈)
查看>>
android 学习资源网址
查看>>
shell基础
查看>>
2018.1.15
查看>>
[集合DP] UVA 10651 Pebble Solitaire
查看>>
qt安装遇到的错误
查看>>
寻找完美平方数
查看>>
java:Apache Shiro 权限管理
查看>>
objective c的注释规范
查看>>
FreeNas安装配置使用
查看>>
机器学习中的F1-score
查看>>
编译安装php5.5.38
查看>>
常用查找数据结构及算法(Python实现)
查看>>
Scrapy框架-CrawlSpider
查看>>
Django(一)框架简介
查看>>
java.lang.OutOfMemoryError: Java heap space
查看>>
popular short sentences
查看>>