#include using namespace std; int i0, i1, i2, i3, i4, i5; int d0, d1; int countD0, countD1, countBoth; // This assignment is worth 5 points. // -1 for not having gramatically correct output // -0.5 if the only grammar error is having 0 with singular verbs // -2 for failing to count the cases for divisible by both divisors correctly int main() { cout << "Enter in six integers: "; cin >> i0 >> i1 >> i2 >> i3 >> i4 >> i5; cout << "Enter in two divisors: "; cin >> d0 >> d1; countD0 = (i0 % d0 == 0) + (i1 % d0 == 0) + (i2 % d0 == 0) + (i3 % d0 == 0) + (i4 % d0 == 0) + (i5 % d0 == 0); countD1 = (i0 % d1 == 0) + (i1 % d1 == 0) + (i2 % d1 == 0) + (i3 % d1 == 0) + (i4 % d1 == 0) + (i5 % d1 == 0); countBoth = (i0 % d0 == 0 && i0 % d1 == 0) + (i1 % d0 == 0 && i1 % d1 == 0) + (i2 % d0 == 0 && i2 % d1 == 0) + (i3 % d0 == 0 && i3 % d1 == 0) + (i4 % d0 == 0 && i4 % d1 == 0) + (i5 % d0 == 0 && i5 % d1 == 0); /* Alternatively, you can do this to count your multiples instead: * * countD0 = !(i0 % d0) + !(i1 % d0) + !(i2 % d0) * + !(i3 % d0) + !(i4 % d0) + !(i5 % d0); * * Because ! would flip the 0 to a 1 and non-zeros to 0. */ if(countD0 != 1) // Grammar check cout << countD0 << " numbers are divisible by " << d0 << '.' << endl; else cout << countD0 << " number is divisible by " << d0 << '.' << endl; if(countD1 != 1) cout << countD1 << " numbers are divisible by " << d1 << '.' << endl; else cout << countD1 << " number is divisible by " << d1 << '.' << endl; if(countBoth != 1) cout << countBoth << " numbers are divisible by both." << endl; else cout << countBoth << " number is divisible by both." << endl; return 0; }