Advertisement
LeYe

Untitled

Feb 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6. int figurate(int num, int sides){
  7. if (sides == 3){
  8. if(num == 1){
  9. return num;
  10. }
  11. else if(num>=2){
  12. num + figurate(num-1,sides);
  13. }
  14. }
  15. else if (sides == 4){
  16. return num*num;
  17. }
  18. else if (sides == 5){
  19. if(num == 1){
  20. return num;
  21. }
  22. else if(num>=2){
  23. num + 2*(num-1) + figurate(num-1,sides);
  24. }
  25. }
  26. return -1;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement