fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int ile_pol(int n) {
  5. return n * n;
  6. }
  7.  
  8. int ile_kolorowych(int n, char kolor) {
  9. if (kolor == 'b')
  10. return n * n / 2;
  11. else
  12. return (n * n -1) / 2 + 1;
  13. }
  14.  
  15. int main() {
  16. for(int i=2; i<=10; i++)
  17. cout << i << " " << ile_pol(i) << " " << ile_kolorowych(i, 'b') << " " <<
  18. ile_kolorowych(i, 'c') << endl;
  19. return 0;
  20. }
  21.  
  22.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
2 4 2 2
3 9 4 5
4 16 8 8
5 25 12 13
6 36 18 18
7 49 24 25
8 64 32 32
9 81 40 41
10 100 50 50