HElp

I need a letter Z and im stuck here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;

int main(){

	int num;
	
	cout << "Type a number: ";
	cin >> num;
	

	for(int j=1;j<=num;j++){
		
		if(j==1 || j==num){
			for (int i=1;i<=num;i++){
				cout << "*";
			}
		}
		else{
			for (int i=1;i<=num;i++){
				if(i==1 || i==num)
				 cout << " ";
				else
				 cout << " ";
			}
		}
		cout << endl;
	}
			
			

cout << endl << endl;

return 0;
}
What is your question?
how do i make it a Z pattern?
Last edited on
Please type the output you are expecting
it should be like this:

*****
.....*
...*
.*
*****

ignore the dots
Last edited on
Now what do you think the underlying mathematical pattern is?
The top and bottom should be easy with a for loop and I see that you already have the top and bottom.

Try writing the other lines as numbers. Each line has one less space. Then try writing a fer loop that can mimic the numbers you wrote down. You are really close already
i changed line line 21 with this
if(j == i)

but its opposite it looks like this

*****
.*
..*
....*
*****
The underlying pattern is to decrease the number of spaces by one every time.
http://ideone.com/FTQsl5
Topic archived. No new replies allowed.