A special site for solving fun programming problems and challenges, interested in computer science, programming, basics, data structure and algorithms

 N. Numbers Histogram

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Given 3 lines of input described as follow:

  1. First line contains a symbol S.
  2. Second line contains a number N.
  3. Third line contains N numbers.

For each number Xi in the N numbers print a new line that contains the symbol S repeated Xi time.

Input

The first line contains a symbol S can be (+,,,/).

The second line an number N (1N50).

The third line contains N numbers (1Xi100).

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


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