this is the output
when enter 1
*********O*
when enter 2
********O**
----------------------------
1*********O*
2********O**
3*******O***
4******O****
5*****O*****
.
.
.
.
.
.
.

help me plss
tnx

Recommended Answers

All 7 Replies

Whats your question, really?
You want help to loop, and include a sample. Please tell us what you want to achieve :)

It looks like you're trying to place a marker ('0') somewhere within a field of eleven stars based on user input, which represents places from the right, starting with zero on the right and ten on the left.

If that's the case, first you'll need to read the input from the user (i.e. the position in which the user desires the '0' to be placed), n. You'll then need to output n-2 '*' characters, the '0' character and then n more '*' characters.

That would be the logic behind doing that and it should be easily achievable using any number of different types of loops. Presumably this is for a class, so check your text book, class notes or online for lessons on how to use loops to do the above if you're not already able to do so.

Whats your question, really?
You want help to loop, and include a sample. Please tell us what you want to achieve :)

uhm
i need the 0 to go diagonal like this

this is the output
when enter 1
*********O*
when enter 2
********O**
----------------------------
1*********O*
2********O**
3*******O***
4******O****
5*****O*****

It looks like you're trying to place a marker ('0') somewhere within a field of eleven stars based on user input, which represents places from the right, starting with zero on the right and ten on the left.

If that's the case, first you'll need to read the input from the user (i.e. the position in which the user desires the '0' to be placed), n. You'll then need to output n-2 '*' characters, the '0' character and then n more '*' characters.

like this?

int n;
        //--- Loop counting n down to 0.
        while (n <= 10) {
            cout << "**";
            n-2;
}

sorry i dont have a code to present
my code is crap

Is this what you are looking for?

#include <iostream>
using namespace std;

int main()
{
	int input;
	cin >> input;
	
	for( int i = 0; i < 10-input; i++ )
		cout << "*";
	cout << "O";
	for( int i = 0; i < input; i++ )
		cout << "*";
	
    system("PAUSE");
    return 0;
}

Is this what you are looking for?

Is this what you're looking for?

:S

Doing his homework for him won't help him learn anything. All the logic required to do the assignment is posted in this thread. If the work was assigned, presumably the coursework has provided OP with the tools necessary to complete it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.