0

please help me fix

i want to write if cin arr[i] [j] = 1,1, my string free become a busy https://code.sololearn.com/cWhYhJG5lJvy/?ref=app

11th Dec 2018, 12:34 PM
Hayko
Hayko - avatar
1 Réponse
+ 4
#include <iostream> #include <string> #include <iomanip> using namespace std; int main() { const int x = 3, y = 3; int sit_number = 0; // added string arr[x][y] = { // fixed {"free","free","free"}, {"free","free","free"}, {"free","free","free"} }; // Before for (int i = 0; i < x; i++) { for (int j = 0;j < y;j++) { cout << setw(15) << arr[i][j] << setw(5); } cout << endl; } for (int i = 0; i < x; i++) { cout << "enter your sit number" << endl; for (int j = 0;j < y;j++) { cin >> sit_number; // fixed if (sit_number == 1) // fixed arr[i][j] = "busy"; // fixed } } // After for (int i = 0; i < x; i++) { for (int j = 0;j < y;j++) { cout << setw(15) << arr[i][j] << setw(5); } cout << endl; } } Sample Output: free free free free free free free free free enter your sit number 5 1 6 enter your sit number 9 3 4 enter your sit number 7 1 8 free busy free free free free free busy free
11th Dec 2018, 12:55 PM
Babak
Babak - avatar