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