#include <iostream> #include <sstream> void draw_arrow(int width, int tail, char draw){ //print head for(int i = 1; i <= width; i+=2){ //print spaces for(int j=0; j<(width-i)/2; j++) std::cout << " "; //print chars for(int j=0; j<i; j++) std::cout << draw; std::cout<<"\n"; } //print tail for(int i = 0; i < width/2; i++){ for(int j=0; j<(width-tail)/2; j++) std::cout << " "; for (int j=0; j<tail; j++) std::cout << draw; std::cout << std::endl; } } int main() { int width_of_arrow = 0; int width_of_tail = -1; char drawing_char = '\0'; std::string input; std::cout << "Input Width of Arrow: "; std::getline(std::cin, input); std::stringstream(input) >> width_of_arrow; std::cout << "Input Width of Tail: "; std::getline(std::cin, input); std::stringstream(input) >> width_of_tail; if (width_of_tail == -1) width_of_tail = 1; std::cout << "Input Drawing Character: "; std::getline(std::cin, input); drawing_char=input[0]; if (drawing_char == '\0') drawing_char = '*'; draw_arrow(width_of_arrow, width_of_tail, drawing_char); return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)