samedi 29 septembre 2018

New to C++, Using if statement if not multiple

I want to create a 5x5 array of '' with a hashtag in the center instead of '', but only when the user inputs either 'a' or 'b.' On the area I marked "RIGHT HERE" it doesn't work unless its ONLY 'a' / ONLY 'b', so what do I do? Thank you in advance!

#include <iostream>

using namespace std;

int main()
{


while (true){

///Variables:

char array[4][4]; //Playing field 5x5
char direc; //Direction player moves




for (int x = 0; x <=4; x++){

    for (int y = 0; y <= 4; y++){

        array[x][y] = '_';
    if (direc != 'a' || 'b'){ ///RIGHT HERE!
        array[2][2] = '#';
    }

        cout << array[x][y]; //Starts printing Board

        if (y == 4){
        cout << endl; //Cuts to next line on print if 4 in a column row
    }

}
}

cin >> direc;
cin.get();




}

}

Aucun commentaire:

Enregistrer un commentaire