<mosaic.cnfolio.com>
PROGRAM
1. /*
2. *In Pokemon Go, you can level up by earning XP.
3. *XP can be earned doing a variety of things.
4. *One way to earn XP is to evolve a pidgey.
5. *Evolving a pidgey requires "pidgey candy" and a pidgey.
6. *It takes one pidgey and 12 pidgey candies to evolve one pidgey.
7. *However, the act of evolving a pidgey gives you 1 candy back.
8. *There is the edge case that if you have 11 pidgey candies, you can not evolve anything.
9. *You can use alchemy to transmute pidgeys into candy. One pidgey yields one candy
10. *Transmuting a pidgey into a candy kills the pidgey.
11. *In addition, the Lucky Egg item doubles XP gains, so evolving a pidgey under the influence of a Lucky Egg yields 1000 XP.
12.
13. *Perhaps something like this:
14.
15. do
16.     read the number of candy
17.     if the number of candy is not correct
18.         print error message
19. while the number of candy less than zero
20.
21. do
22.     read the number of pidgey
23.     if the number of pidgey is not correct
24.         print error message
25. while the number of pidgey less or equal than zero
26.
27. if the number of candy less than 11 and pidgey equal one
28.     print can not evolve
29. else if the number of candy greater than 11 and pidgey equal one
30.     total XP plus 1000
31. else
32.     while the number of candy and pidgey greater than 11 and one respectively
33.         increases total XP by 1000
34.         reduces the number of candy by 10
35.         reduces the number of pidgey by one
36.     while the number of pidgey greater than one
37.         reduces the number of pidgey by one
38.         increases the number of candy by one
39.         if the number of candy greater than 11
40.             increases total XP by 1000
41.             reduces the number of candy by 10
42. print total XP gained
43. */
44.
45. #include <stdio.h>
46. int main()
47. {
48.    int candies, pidgeys, XP = 0;
49.
50.    do
51.     {
52.         printf("\nNumber of candies: ");
53.         scanf("%d", &candies);
54.         if(candies < 0)
55.         {
56.             printf("\nError !!!");
57.         }
58.     }while(candies < 0 );
59.
60.     do
61.     {
62.         printf("\nNumber of pidgeys: ");
63.         scanf("%d", &pidgeys);
64.         if (pidgeys <=0 )
65.         {
66.             printf("\nError !!!");
67.         }
68.     }while(pidgeys <= 0 );
69.
70.     if (candies < 11 && pidgeys == 1)
71.     {
72.         XP=0;
73.         printf("\nCan not evolve");
74.     }
75.
76.     else if (candies > 11 && pidgeys == 1)
77.     {
78.         XP = 1000;
79.     }
80.     else
81.     {
82.         while (candies >= 11 && pidgeys > 1)
83.         {
84.             XP = XP + 1000;
85.             candies = candies - 10;
86.             pidgeys--;
87.
88.         }
89.         while (pidgeys > 1)
90.         {
91.             pidgeys--;
92.             candies++;
93.             if (candies > 11)
94.             {
95.                 candies = candies - 10;
96.                 XP = XP + 1000;
97.             }
98.         }
99.     }
100.      printf("\nTotal XP : %d", XP);
101. }