fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int fun(int a) {
  5. return a*a + 2*a + 1;
  6. }
  7.  
  8. int boring(int a) {
  9. return (a + 1) * (a - 1);
  10. }
  11.  
  12. void out_of_space(int n) {
  13. cout << "Hello Space!\n";
  14. }
  15.  
  16. int main() {
  17. int n; cin >> n;
  18. switch(n%3) {
  19. case 1: cout << fun(n) << endl; break;
  20. case 2: cout << boring(n) << endl; break;
  21. case 0: out_of_space(n);
  22. }
  23. }
Success #stdin #stdout 0s 15240KB
stdin
1568
stdout
2458623