Hello everyone,
I am attempting to create a diamond pattern, and failing miserably. I am looking for some info on getting my proggie running
Each dash represents a space. It is supposed to be monospace. Notice it goes 1-3-5-3-1. Here is an example of it working:
----x
--xxx
xxxxx
--xxx
----x
I know I need a few "for" loops. Outer for counting spaces and inner couple for counting and displaying spaces and numbers.
Here's what I have so far...
NEW CODE ADDED.
Code:#include <iostream> #include <string> using namespace std; int main() { int num; char character; cout << "Enter Number: "; cin >> num; int half=(num/2); cout <<half<<endl; while (num>0){ cout << "Enter character: "<<endl; cin >> character; cout <<endl; for (int row=0;row<num;++row) { int numplus1=num++; for (int space=((numplus1/2)-row);space<=row;++space){ cout <<" "; cout <<endl; for (int display=num-((numplus1)-(2*row));display<=num;display++){ cout <<character; cout <<endl; }} for (int space=((numplus1/2)-row);space<=row;++space){ cout <<" "; cout <<endl; for (int display=num-((numplus1)-(2*row));display<=num;display++){ cout <<character; cout <<endl; }} cout << "\nEnter Number: "; cin >> num; } cout <<endl; cout << "Bye"<<endl; system("PAUSE"); return 0;} }



LinkBack URL
About LinkBacks



