Need help with a small fraction of code!

hi i dont know how to make the stars go to the left instead of the right of the 0 line! please help my assignment is due in the next hour!

to the left of the line is the negative values. here's a sample

http://i43.tinypic.com/16lep83.jpg

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;


void header();
void pos(int,int);
void neg(int,int);


int main()
{
    
    header();
    
    int temp,sym;
    ifstream inFile;
    inFile.open("C:\\Users\\Peter\\Documents\\CSP31A\\Assignment3question2.txt");
    
    if(!inFile){
          cout << "\nOpen file not successful";
    }
    
    inFile >> temp;
    
    while(inFile)
    {      
           if( temp>=-30 && temp <=120)
           {
               cout << setw(8) << temp;
               sym = temp/3;
               if (temp>0)
               {
               pos(sym,temp);
               }
               else if (temp<0)
               {
               neg(sym,temp) ;         
               }
           } inFile >> temp;
           cout << endl;
    }
system ("PAUSE");   
return 0;
}

void header()
{
     cout << setw(15) <<"-10" << setw(15) <<"0"<< setw(15)<<"10"<< setw(15)<< "20" << setw(15) << "30" << endl;
}

void pos(int sym,int j)
{
     int x;
     if (j!=1 || j!=2)
     {
           cout << setw(22) << "|";
     }
     for(x=0;x<sym;x++)
     {
           cout << "*";
                     
     }
}
void neg(int sym,int j)
{
     int x;
     cout <<setw(20);
     for (x=0;x>sym;x--)
     {
         cout << "*" ;
          
     }
     if (j != -1 || j != -2)
     {
           cout << "|";
     }
     
     
}
closed account (o3hC5Di1)
Hi there,

I'm not a 100% sure what you're asking, but if you need to outline things to the right, you'll probably want to have a look at: http://www.cplusplus.com/reference/ios/right/

Note that there is also a: http://www.cplusplus.com/reference/ios/left/

All the best,
NwN

ive looked at that already and the problem is that is for a long list or strings or numbers that are in the same line statement

i am trying to print each star one at a time with it printing to the left :\
closed account (o3hC5Di1)
Could you please give an example of the output you want?

All the best,
NwN
its in the link in the first post. its alrite if you dont want to show me. i turned in what i got lol.

it'd be nice to know though :D!
Topic archived. No new replies allowed.