My issue
int T;
cin >> T; // Number of test cases
while (T–) {
int N;
cin >> N;
if (N % 3 == 0) {
// If N is a multiple of 3, Bob wins
cout << "BOB" << endl;
} else {
// If N is not a multiple of 3, Alice wins
cout << "ALICE" << endl;
}
}
return 0;what is wrong in the logic?
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T; // Number of test cases
while (T--) {
int N;
cin >> N;
if (N % 3 == 0) {
// If N is a multiple of 3, Bob wins
cout << "BOB" << endl;
} else {
// If N is not a multiple of 3, Alice wins
cout << "ALICE" << endl;
}
}
return 0;
}
Problem Link: Add 1 or 2 Game Practice Coding Problem