<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. Obtain the number of pidgey
  4. Obtain the number of candy
  5. IF the Pidgey Candy is less than 12
  6.    THEN dispay "Please insert more candies"
  7. END IF
  8. IF the pidgey is less than 1
  9.    THEN display "Please insert more pidgeys"
  10. END IF
  11. WHILE the candy is more than or equal to 12 and more than or equal to 1 pidgey
  12.    Do the evolution
  13.    Subtract 12 candies from inventory
  14.    Add 1 candey to inventory
  15.    Subtract 1 pidgey from inventory
  16. END WHILE
  17. Calculate the total number of evolution
  18. Calculate the maximum amount of experience
  19. END */
  20.  
  21. #include <stdio.h>
  22. int main(void)
  23. {
  24. int pidgey=0;
  25. int candy=0;
  26. int evolution=0;
  27. int experience=0;
  28. scanf("%d %d",&pidgey, &candy );
  29. if(candy < 12)
  30. {
  31. printf("ERROR: Please insert more candies\n");
  32. }
  33. if(pidgey<1)
  34. {
  35. printf("ERROR: Please insert more pidgeys\n");
  36. }
  37. while(candy>=12 && pidgey>=1) /* Reason behind using while loop is that you dont know how many times the program is going to be repeated*/
  38. {
  39. candy=candy-12;
  40. candy++;
  41. pidgey--;
  42. evolution++;
  43. }
  44. experience=evolution*1000;
  45. printf("The number of evolutions is %d and the XP gained is %d", evolution, experience);
  46. }