<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.        set the number of pidgeys, candies and evolutions to start at zero
  4.        obtain number of pidgeys and candies
  5.     IF the number of candies is fewer than twelve
  6. THEN
  7.        display error message one
  8. END IF
  9.     ELSE IF the number of pidgeys is zero or less
  10. THEN
  11.        display error message two
  12. END IF
  13.  
  14.     WHILE the number of candies is at least twelve and the number of pidgeys is at least one
  15.           obtain number of pidgeys and candies
  16.           minus twelve from candies
  17.           minus one from pidgeys
  18.           add one to evolutions
  19.           add one to candies
  20. END WHILE
  21.       multiply the number of evolutions by one thousand and set as XP
  22.       display the maximum XP
  23. END     
  24. */
  25.  
  26. #include<stdio.h>
  27. int main( void )
  28. {
  29. int pidgeys = 0;
  30. int candies = 0;
  31. int evolutions = 0;
  32. scanf("%d %d", &pidgeys, &candies);
  33.  
  34. if (candies < 12)
  35. {
  36. printf("ERROR: At least 12 pidgey candies are required for a pidgey evolution and make sure the input is a positive integer.\n");
  37. exit(0);
  38. }
  39. else if (pidgeys <= 0)
  40. {
  41. printf("ERROR: There must be at least one pidgey to evolve and there can't be a negative amount of pidgeys.\n");
  42. }
  43.  
  44. while(candies >= 12 && pidgeys >= 1)  /* Here a while loop is used as there is a repeated process*/
  45. {
  46. scanf( "%d %d", &pidgeys, &candies);
  47. candies = candies - 12;
  48. pidgeys--;
  49. evolutions++;
  50. candies++;
  51. }
  52. int XP = evolutions * 1000;
  53. printf("The maximum XP you can earn whilst using a lucky egg is %d XP.", XP);
  54. }