Advertisement
CzarnyBarszcz

gotowka

Feb 4th, 2020
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. double gotowka(double startowa,int n);
  7. double gotowka1(double startowa,int n);
  8.  
  9.  
  10.  
  11. int main()
  12. {
  13. int n;
  14. double start;
  15. cout<<"ile miesiecy? :";
  16. cin>>n;
  17. cout<<"gotowka : ";
  18. cin>>start;
  19. cout<<gotowka(start,n)<<endl;
  20. cout<<gotowka1(start,n);
  21.     getch();
  22.     return 0;
  23. }
  24. double gotowka(double startowa,int n)
  25. {
  26.  
  27.     for(int i=1;i<=n;i++)
  28.     {
  29.         startowa = (startowa*1.05)-10;
  30.     }
  31.     return startowa;
  32. }
  33.  
  34. double gotowka1(double startowa,int n)
  35. {
  36.     if(n<1)
  37.         return startowa;
  38.  
  39.     return gotowka1(startowa=(startowa*1.05)-10,n-1);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement