Question

Drawing Characters C++ Problem Description Annie is trying to draw character lines that she would like...

Drawing Characters C++

Problem Description

Annie is trying to draw character lines that she would like to use as decorations in her text messages to her friends. She has a list of integer and character pairs that she uses as basis for drawing out the lines. Write a program that will help her accomplish the task more quickly.

Input Format

The input begins with an integer N indicating the number of integer and character pairs that follows.

The succeeding lines are pairs of an integer T and a character C, where denotes how many characters should be printed to create the line. The T and C pairs are separated by a space. C could be any of the following characters: *, #, @

Output Format

For each T and C pair, print number of character/s with no spaces in between. Drawn lines for each pair must be in its own line in the output. If is not among the acceptable characters, print "Cannot draw!" without the quotation marks.

Constraint

1 <= N <= 100

1 <= T <= 100

C can be any of the following: *, #, @

Sample Input

3
5 *
10 @
15 #

Sample Output

*****
@@@@@@@@@@
###############
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:


#include <iostream>

using namespace std;

int main()
{
int n;
cin>>n;
  
for(int i=0; i<n; i++)
{
int t;
char c;
cin>>t>>c;
if(c!='*' && c!='#' && c!='@')
{
cout<<"Cannot Draw!"<<endl;
}
else
{
for(int j=0; j<t; j++)
{
cout<<c;
}
cout<<endl;
}
}

return 0;
}

Output:

This is the correct code!

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

Add a comment
Know the answer?
Add Answer to:
Drawing Characters C++ Problem Description Annie is trying to draw character lines that she would like...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please I need help with the question: Problem: Write a C++ program that reads each character...

    please I need help with the question: Problem: Write a C++ program that reads each character from a user input, extracts the character if it is a digit, and calculates the sum of all the digits. The program stops reading the user input when the new line character ‘\n’ is encountered. For the output of the program, you should print each digit extracted from the user input and the sum of all the digits. (*The main difference between “cin >>...

  • (Packing Characters into an Integer) The left-shift operator can be used to pack four character values into a four-byt...

    (Packing Characters into an Integer) The left-shift operator can be used to pack four character values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an unsigned int variable, assign the first character to the unsigned intvariable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator....

  • C++ please! In this program you will be outputting the characters that map to the ASCIl...

    C++ please! In this program you will be outputting the characters that map to the ASCIl codes 32 through 126. You will need a loop to iterate through the input values and output the corresponding character. This mapping is shown in appendix A in your Gaddis text book. Your program will be reading in two unsigned integer values. The prompt for read will be Enter lower and upper values You need to check that both values are in the range...

  • What’s the C++ code to this? So that my output is: CCTAGAATG | | X |...

    What’s the C++ code to this? So that my output is: CCTAGAATG | | X | | X | | GGACCTAAC Validity: 77.7778% Stability: 57.1429% Part #02 The goal is to write a complete C++ program that inputs 2 strings from the keyboard, where each string denotes a DNA strand such as CCTAGAATG. Assume the 2 strings are the same length. The program will then CS 109: htp:/bwww.csic.edu i109 Page I of 3 line up the two strands to see...

  • //C++ Problem description In this problem, we consider expressions containing brackets that are properly nested. These...

    //C++ Problem description In this problem, we consider expressions containing brackets that are properly nested. These expressions are obtained by juxtaposition of properly nested expressions in a pair of matching brackets, the left one an opening and the right one a closing bracket. ( a + $ ( b = ) ( a ) ) is properly nested ( a + $ ) b = ) ( a ( ) is not In this problem we have several pairs of...

  • C++ program to convert between decimal, hexadecimal, and octal. Please Help!!

    Hi, I need help writing a program that reads in data (hex, octal or decimal values) from an input file and outputs the values in to another base form (hex, octal,decimal) one line at a time depending on the formatting characters provided by the input file. I am posting the code requirements below and an example of what theinput file will look like and what should be output by the program. I only need the one .cpp program file. Thanks...

  • Write in C language . Thank you Count Sheep Jojo is having problem to sleep at...

    Write in C language . Thank you Count Sheep Jojo is having problem to sleep at night. He can't fall asleep and it makes him feel tired every day. Having this problem, Jojo told his friend Bibi, and Bibi advised him to do sheep counting while he tries to sleep. Jojo decided to try using this trick for N nights, to test its effectiveness. Jojo realized that he would fall asleep if he imagined a total of 10 white sheep....

  • C++ programing question22 Minimum spanning tree Time limit: 1 second Problem Description For a connected undirected...

    C++ programing question22 Minimum spanning tree Time limit: 1 second Problem Description For a connected undirected graph G = (V, E), edge e corresponds to a weight w, a minimum weight spaning tree can be found on the graph. Into trees. Input file format At the beginning, there will be a positive integer T, which means that there will be T input data. The first line of each input has two positive integers n,m, representing n points and m edges...

  • Java 8 Braces You are designing a compiler for a C++ program and need to check...

    Java 8 Braces You are designing a compiler for a C++ program and need to check that braces in any given file are balanced Braces in a string are considered to be balanced if the following criteria are met: All braces must be closed. Braces come in pairs of the form 0.0andl1. The left brace opens the pair, and the right one closes it In any set of nested braces, the braces between any pair must be closed For example,...

  • C language huffman This exercise will familiarize you with linked lists, which you will need for...

    C language huffman This exercise will familiarize you with linked lists, which you will need for a subsequent programming Getting Started assignment Overview Requirements Getting Started Submit Start by getting the files. Type 264get hw13 and then cd hw13 from bash. Pre-tester You will get the following files: Q&A Updates 1. huffman.h: An empty header file, you have to define your own functions in this homework. 2. huffman.c: An empty c file, you have to define your own functions in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT