UVa 488 - Triangle Wave

题目:给出波的振幅和平率,用数字绘制出波形图。

分析:简单题。输入输出练习。

#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main()
{
	int n,a,f;
	while ( scanf("%d",&n) != EOF ) 
	for ( int i = 1 ; i <= n ; ++ i ) {
		scanf("%d%d",&a,&f);
		for ( int j = 1 ; j <= f ; ++ j ) {
			for ( int k = 1 ; k <= a ; ++ k ) {
				for ( int l = 1 ; l <= k ; ++ l )
					printf("%d",k);
				printf("\n");
			}
			for ( int k = a-1 ; k >= 1 ; -- k ) {
				for ( int l = 1 ; l <= k ; ++ l )
					printf("%d",k);
				printf("\n");
			}
			if ( j < f ) printf("\n");
		}
		if ( i < n ) printf("\n");
	}
	return 0;
}

你可能感兴趣的:(UVa 488 - Triangle Wave)