Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,800 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,351 people online right now. Registration is fast and FREE... Join Now!




right triangle using asterisk (*)

 
Reply to this topicStart new topic

right triangle using asterisk (*), Help me pls in c++

kurorokhristoffer
3 Oct, 2008 - 04:52 AM
Post #1

New D.I.C Head
*

Joined: 3 Oct, 2008
Posts: 3

hello guys, please help me here, i want to make this like figure in c++ using asterisk(*);

******`````````*
`*****````````**
``****```````***
```***``````****
````**`````*****
`````*````******

Something like that.. i already made one. But i need another figure just like at the top
CODE

#include<iostream>
using namespace std;
int main()
{
    int value = 11;
    for(int i = (value - 1); i > 0; i--)
{
for(int j = 0; j < i; j++)
cout << "*" << flush;

cout << "" << endl;
}
return 0;
}


Please help me,..
A little help is a million thanks !!

This post has been edited by jayman9: 3 Oct, 2008 - 07:42 AM
User is offlineProfile CardPM
+Quote Post

bbq
RE: Right Triangle Using Asterisk (*)
3 Oct, 2008 - 06:44 AM
Post #2

D.I.C Head
Group Icon

Joined: 15 May, 2008
Posts: 192



Thanked: 17 times
Dream Kudos: 50
My Contributions
Was bored so decided to have a go at it, hope this helps and i am certain there is an easier way to do this however thats up to you icon_up.gif

cpp

/* ===== Program To Print Pattern ====== */

/* Pattern

******`````````*
`*****````````**
``****```````***
```***``````****
````**`````*****
`````*````******
*/

#include<iostream>

using namespace std;

void printPattern()
{
char charArray[] = {'*','*','*','*','*','*','`','`','`','`','`','`','`','`','`','*'};

//variables
int counter = 0;
char temp;
int value1 = 0, value2 = 14;

while (counter < 6)
{
//print out the array
for(int k = 0; k < 17; k++)
cout << charArray[k];
cout << endl; //newline

//manipulate the array

temp = charArray[value1]; // *
charArray[value1] = charArray[value2];
charArray[value2] = temp;

value1++; value2--;
counter++;

}
}

int main()
{
cout << "Patter Printer v1\n=======================" << endl;

printPattern();

return 0;
}


Hope this helps a bit. pirate.gif
User is offlineProfile CardPM
+Quote Post

Sadaiy
RE: Right Triangle Using Asterisk (*)
4 Oct, 2008 - 03:35 PM
Post #3

New D.I.C Head
*

Joined: 3 Oct, 2008
Posts: 38



Thanked: 1 times
My Contributions
ok for this you need one master loop that is iterated to 6 for the 6 lines of * or `.. Inside that loop you need four separate loops (seperate NOT nested) that are either incrementing or decrementing and outputting the correct character...
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 01:53PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month