fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int ile_kolorowych(int n, char kolor) {
  5. if (kolor == 'b')
  6. return n * n / 2;
  7. else
  8. return (n * n - 1) / 2 + 1;
  9. }
  10.  
  11. int main() {
  12. cout << ile_kolorowych(8, 'b') << endl;
  13. cout << ile_kolorowych(8, 'c') << endl;
  14. cout << ile_kolorowych(7, 'b') << endl;
  15. cout << ile_kolorowych(7, 'c') << endl;
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
32
32
24
25