Jeremiah_

1160 - Crescimento Populacional(Population Increase)

May 9th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t, pa, pb;
  8.     double ga, gb;
  9.     cin >> t;
  10.     for(int i=0; i<t; i++){
  11.         cin >> pa >> pb >> ga >> gb;
  12.         int anos = 0;
  13.         ga = ga/100;
  14.         gb = gb/100;
  15.         while(pa<=pb){
  16.             pa += ga*pa;
  17.             pb += gb*pb;
  18.             anos++;
  19.             if(anos == 101)
  20.                 break;
  21.         }
  22.         if(anos>100){
  23.             cout << "Mais de 1 seculo." << endl;
  24.         }else{
  25.             cout << anos << " anos." << endl;
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment