As wave is defined in problem 10768, a character wave consistss of lines of characters, which has a parameter, length L. The number of characters in the first line is 1, and is increased by one in the every following lines. After the number of character reaches L, it starts to descrease until the number of characters become 1 again.
Print out N character waves consequtively. Each wave is built by the character C and the length is L.
Note that
1. This problem involves three files.
You will be provided with main.cpp and function.h, and asked to implement function.cpp.
2. For OJ submission:
Step 1. Submit only your function.cpp into the submission block. (Please choose c++ 11 compiler)
Step 2. Check the results and debug your program if necessary.
3. You only need to handle waves of length greater the one. And main program already takes care of the last line of the output.
function.h
#ifndef FUNCTION_H
#define FUNCTION_H
int length_greater_than_one(char c, int length, int n);
#endif
main.cpp
#include <stdio.h>
#include "function.h"
int main(void){
char c;
int length, n, i;
scanf("%c %d %d", &c, &length, &n);
if (length>1)
length_greater_than_one(c, length, n);
else {
for (i=0; i<n-1; i++)
printf("%c\n", c);
}
// print the last line
printf("%c", c);
return 0;
}
There are three inputs, separated by a space. The first one is a character C; the second one and the third one are integers, specifying the length L and the number of waves N to print.