题目大意:
给你振幅和频率,让你画出波形。
如:
3
2
波形为:
1
22
333
22
1
1
22
333
22
1
#include <iostream> using namespace std; void print(int a, int b); int main() { int n, leap, a, b; cin >> n; leap = 0; while(n--){ if (leap != 0) // cout << "CR"<<endl; cout << endl; leap++; cin >> a >> b; print(a, b); } } //a为振幅,b为频率 void print(int a, int b) { for (int i = 0; i < b; i++){ //一共打印b个波浪 for (int j = 1; j < a; j++){ //打印波峰之前 for (int k = 1; k <= j; k++){ //打印每行 cout << j; } cout << endl; } for (int j = 1; j <= a; j++){ //打印波峰 cout << a; } for (int j = a - 1; j >= 1; j--){ //打印波峰之后 for (int k = 1; k <= j; k++ ){ //打印每行 cout << j; } cout << endl; } if(i != b - 1) // cout << "LF" << endl; cout << endl; } }