<mosaic.cnfolio.com>
PROGRAM
1. /*
2. START
3.    Read the inputted number of Pidgey's and Candies
4.    Calculate the number of Evolutions possible
5.    IF the number of Pidgey's or the number of Candies is equal to zero
6.       THEN
7.          Display that a valid input needs to be put in
8.    ELSE IF the number of Pidgey's is less than zero or the number of Candies is less than zero
9.       THEN
10.          Display that a valid number of Pidgey or Candies should be input
11.    ELSE
12.       THEN
13.          WHILE the number of Pidgey is greater than or equal to the number of possible evolutions and the number of possible evolutions is greater than 0
14.             Decrease the number of Candies by 12
15.             Increase the XP with a lucky egg by 1000
16.             Decrease the number of Pidgey by 1
17.             Increase the number of Candies by 1
18.             Decrease the number of Possible Evolutions by 1
19.          END WHILE
20.          WHILE the number of possible evolutions is greater than or equal to the number of Pidgey's and the number of Pidgey's is greater than zero
21.             Decrease the number of Candies by 12
22.             Increase the XP with a lucky egg by 1000
23.             Decrease the number of Pidgey by 1
24.             Increase the number of Candies by 1
25.             Decrease the number of possible evolutions by 1
26.          END WHILE
27.          The number of Evolutions is equal to the XP with a lucky egg divided by 1000
28.          The XP without a lucky egg is half the XP with a lucky egg
29.          The Candies Used is equal to the number of Evolutions that occur multiplied by 12
30.    END IF
31.    IF the number ov evolutions is greater than 60
32.       THEN
33.          Display that the user might need to use more than 1 lucky egg
34.    END IF
35.    IF the number of evolutions that occur is equal to 1
36.       THEN
37.          Display how many Pidgey's they can evolve, how many Candies would be used and how many Candies they'd have left
38.          Display the XP gained without a lucky egg and the XP gained when using a lucky egg
39.    ELSE IF the evolutions are greater than 1
40.       THEN
41.          Display how many Pidgey's they can evolve, how many Candies would be used and how many Candies they'd have left
42.          Display the XP gained without a lucky egg and the XP gained when using a lucky egg
43.    END IF
44. END
45. */
46. #include <stdio.h>
47. int main()
48. {
49.    int Pidgey = 0;
50.    int Candies = 0;
51.    int Evolutions = 0;
52.    int PossibleEvolutions = 0;
53.    int XPWithLuckyEgg = 0;
54.    int XPWithoutLuckyEgg = 0;
55.    int CandiesUsed = 0;
56.    scanf("%d %d", &Pidgey, &Candies);
57.    PossibleEvolutions = Candies / 12;
58.    if ((!Pidgey) || (!Candies))
59.       {
60.          printf("Please input valid values before running the program.\n");
61.       }
62.    else if ((Pidgey < 0) || (Candies < 0))
63.       {
64.          printf("Please input a valid number that is greater than 0.\n");
65.       }
66.    else
67.       while ((Pidgey >= PossibleEvolutions) && (PossibleEvolutions > 0))
68.          {
69.             Candies -= 12;
70.             XPWithLuckyEgg += 1000;
71.             --Pidgey;
72.             Candies++;
73.             --PossibleEvolutions;
74.          }
75.       while ((PossibleEvolutions >= Pidgey) && (Pidgey > 0))
76.          {
77.             Candies -= 12;
78.             XPWithLuckyEgg += 1000;
79.             --Pidgey;
80.             Candies++;
81.             --PossibleEvolutions;
82.          }
83.          Evolutions = XPWithLuckyEgg / 1000
84.          XPWithoutLuckyEgg = XPWithLuckyEgg / 2;
85.          CandiesUsed = Evolutions * 12;
86.    if (Evolutions >= 60)
87.       {
88.          printf("You might need to use more the one lucky egg to perform this many evolutions.\n");
89.       }
90.    if (Evolutions == 1)
91.       {
92.          printf("You can evolve %d Pidgey using a total of %d Candies and will have %d Candies at the end.\n", Evolutions, CandiesUsed, Candies);
93.          printf("Without using a Lucky Egg you would earn %d XP.\nHowever if you use a Lucky Egg, you will earn %d XP.\n", XPWithoutLuckyEgg, XPWithLuckyEgg);
94.       }
95.    else if (Evolutions >1)
96.       {
97.          printf("You can evolve %d Pidgey's using a total of %d Candies and will have %d Candies at the end.\n", Evolutions, CandiesUsed, Candies);
98.          printf("Without using a Lucky Egg you would earn %d XP.\nHowever if you use a Lucky Egg, you will earn %d XP.\n", XPWithoutLuckyEgg, XPWithLuckyEgg);
99.       }
100. }