If it's an integer and it's negative, it'll print the '-' sign for you. You don't have to do that yourself.
The only thing you have to worry about is reading in 'n', and then reading n more characters.
n is an integer that the user enters, so you should make another integer to store it. You already know that there will be exactly n orders, so you only have to read those in that many times.
Since
a
is a character, you should compare it to other characters using single quotes
''
, like
'>'
or
'<'
You should use
if (a == '>')
And make sure to use
==
for comparison.
=
makes assignments, so it will change the value of
a
if you use
=
.
==
compares the left and right arguments.
You have the right idea about counting, but change
if (a = ">")
,
""
is used for strings, and the
=
will actually change the value of
a
instead of comparing it something else.
You should initialize your variables, because right now
b
will just have some junk value that was in memory, as will
c
.
Just set some initial value when you declare your variables
1 2
|
int b = 0; //b should start counting from 0, shouldn't it?
char c = 'n'; //Or whatever initial value you want it to have
|
Hint: You can put the
cin
for reading in the orders in a loop. How many times should that loop execute?