N. Numbers Histogram
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputGiven 3 lines of input described as follow:
- First line contains a symbol .
- Second line contains a number .
- Third line contains numbers.
For each number in the numbers print a new line that contains the symbol repeated time.
Input
The first line contains a symbol can be .
The second line an number .
The third line contains numbers .
Output
Print the answer required above.
Example
input
Copy
+
5
5 2 4 3 7
output
Copy
+++++
++
++++
+++
+++++++
Note
Don't print any extra spaces after symbol .
my solution:
#include<iostream>
using namespace std;
int main()
{
int n, x;
char ch;
cin >> ch >> n;
for (int i = 0; i < n; i++)
{
cin >>x;
for (int i = 0; i < x; i++)
{
cout << ch;
}
cout << "\n";
}
return 0;
}
No comments:
Post a Comment