Advertisement
PROFESSOR_AIH

Population Increase

Apr 10th, 2022
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int m,pa,pb,year,tcase;
  5.     float ga,gb;
  6.     scanf("%d",&tcase);
  7.     for(m=1; m<=tcase; m++)
  8.     {
  9.         year=0;
  10.         scanf("%d %d %f %f",&pa,&pb,&ga,&gb);
  11.         while(pa<=pb)
  12.         {
  13.             pa=pa+(pa*ga/100);
  14.             pb=pb+(pb*gb/100);
  15.             year++;
  16.             if(year>100)
  17.             {
  18.                 printf("Mais de 1 seculo.\n");
  19.                 break;
  20.             }
  21.         }
  22.         if(year<=100)
  23.             printf("%d anos.\n",year);
  24.     }
  25.  
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement