#include <iostream>
usingnamespace std;
int main()
{
char character;
int i, it;
cin >> character;
if ( character == 'c' ) {
for( i = 1 ; i <= 9 ; i++ ){
cin >> character;
if (character == 'b'){
for( it = 9; it > 1 ; it-- );
cout << "Variable is " << character << ' ' << it-- << endl;
}}}
return 0;
}
I want to run the loop 9 times when i pres c( see line 8), and when i press b i want to output from the last to the first.
My output is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
c
c
c
c
c
c
b
Variable is b 1
b
Variable is b 1
b
Variable is b 1
b
Variable is b 1
but i want to output this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
c
c
c
c
c
c
b
Variable is c(from line 6) 9
b
Variable is c(from line 5) 8
b
Variable is c(from line 4) 7
b
Variable is c(from line 3) 6
b
Variable is c(from line 2) 5
b
Variable is c(from line 1) 4