Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int crecimento(int pop_a, int pop_b, float crec_a, float crec_b)
  5. {
  6. int anos;
  7.  
  8. if(pop_a<pop_b&&crec_a>crec_b)
  9. {
  10. for(anos=0;pop_a<=pop_b;anos++)
  11. {
  12. pop_a+=crec_a;
  13. pop_b+=crec_b;
  14. }
  15. return anos;
  16. }
  17. else if(pop_b<pop_a&&crec_b>crec_a)
  18. {
  19. for(anos=0;pop_a<=pop_b;anos++)
  20. {
  21. pop_b+=crec_b;
  22. pop_a+=crec_a;
  23. }
  24. return anos;
  25. }
  26. else
  27. {
  28. return 0;
  29. }
  30. }
  31.  
  32.  
  33. int main()
  34. {
  35. int pop_a,pop_b;
  36. float nat_a,nat_b,mort_a,mort_b;
  37.  
  38. scanf("%d", &pop_a);
  39. scanf("%f", &nat_a);
  40. scanf("%f", &mort_a);
  41. scanf("%d", &pop_b);
  42. scanf("%f", &nat_b);
  43. scanf("%f", &mort_b);
  44. printf("%d", crecimento(pop_a,pop_b,pop_a*(nat_a/100)-pop_a*(mort_a/100),pop_b*(nat_b/100)-pop_b*(mort_b/100)));
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement