c++ beginner help please!

\//////////
\\/////////
\\\////////
\\\\///////
\\\\\//////
\\\\\\/////
\\\\\\\////
\\\\\\\\///
\\\\\\\\\//
\\\\\\\\\\/

-this suppose to look like of the out come

#include <iostream>
using namespace std;
int main()
{
int z=0;
int i, j;
int spaces;
int g=2;

for (i=1; i<10; i++)
{
for (spaces=g; spaces>0; spaces--)
{
cout << " \\";
}
for (j=0; j<z; j++)
{
cout << "/";
}
cout << endl;
z+=1;
g--;
}
system("pause")

i can't figure it out please help.
Last edited on
It looks as if you're making it more complicated than necessary.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

int main()
{
    int i, j;

    for (i=0; i<10; i++)
    {
        for (j=0; j<11; j++) // i count 11 chars in each line
        {
            if (i>=j)
            {
                cout << "\\"; // we need to escape the backslash
            }
            else
            {
                cout << "/";
            }
        }
        cout << endl;
    }
    system("pause");
}
Last edited on
oh wow -.-

oh i get it now, because i dnt really understand the "for" statement in the middle ,so it count how many chars there is.

i found out abt the backaslash by experiment

and thank you so much
how can I create a program that will accept 2two integers. the user will also choose among the different operations:
1 for addition
2 for subtraction
3 for multiplication
4 for division
EditReportDelete
Reply
Topic archived. No new replies allowed.