<mosaic.cnfolio.com>
PROGRAM
1. /* START
2. Obtain amount pidgey pokemons, p
3. Obtain amount of pidgey candies , c
4.
5. IF amount of pidgey pokemon is less or equal to 0.
6.    THEN
7.    Display "No pokemon to evolve" and stop the program
8. END IF
9. IF amount of pidgey candies is less than 12.
10.    THEN
11.    Display "Not enough candies for evolution" and stop the program
12. END IF
13.
14. IF there is user input "zubat"
15.   THEN
16.   IF amount of pokemon is less or equal to 0.
17.    THEN
18.    Display "No zubat pokemon to evolve" and stop the program
19.    END IF
20.   IF amount of candies is less than 50.
21.    THEN
22.    Display "Not enough zubat candies for evolution" and stop the program
23.   END IF
24. END IF
25. IF the amount of pokemons and pokemon candies is correct.
26. Check how many evolutions are possible by comparing the amount of pokemons and the amount of possible evolutions with candies
27. and do the calculations corresponding to either pidgey or zubat, 12 candies for pidgey and 50 candies for zubat
28. IF the amount of pidgey pokemons is higher than the maximum number of possible evolutions with candies,i.e. the
29.     user has more pokemon and not enough candies to evolve all of them
30.       THEN
31.        Display the amount of possible evolutions by dividing the candies by 11,
32.        11 because the amount required to evolving a pidgey  is 12 and when you evolve a pokemon you get 1 candy back
33.        which makes the mean price of a evolution 11 candies
34.        Display the experiance gained by multiplying the possible evolutions by 1000
35.        its 1000 because an evolution gives 500xp and by using a lucky egg,which doubles xp gains, it goes to
36.        1000 per evolution
37.        Display the amount of pokemon left after evolutions by subtracting the possible evolutions from the total
38.        number of pokemon
39.        Display the amount of candies left by subtracting the required candy for all the possible evolutions from
40.        the total amount of candies and adding 1 candy for each evolved pokemon
41.      END IF
42.     IF the amount of pokemons is less or equal to the maximum number of evolutions possible with candies, i.e. the
43.     user does not have enough pokemon to use all of the candies
44.       THEN
45.       Display the amount of possible evolutions which is the number of pokemon
46.       Display the amount of experiance points, which is calculated by multiplying the number of pokemon by 1000
47.       Display the amount of pokemon left by subtracting the amount of evolved pokemon, which is 0 in all cases
48.       Dsiplay the amount of candies left by subtracting the amount of candies needed for all evolutions from the
49.       total number of candies and add 1 candy for each evolution
50.
51.   END */
52.
53. #include<stdio.h>
54. #include<string.h>
55.   int main ()
56.   {
57.   int p, pidgeys;
58.   int c, candies;
59.   char str[ 10 ] ;
60.   char zubat [ 0 ];
61.
62.   scanf("%d %d", &p, &c);
63.   if ( p <= 0)
64.   {
65.    printf( "No pokemon to evolve \n");
66.    return 0;
67.   }
68.
69.   if ( c < 12 )
70.   {
71.   printf( "Not enough candies for evolution \n");
72.   return 0;
73.   }
74.
75.           if ( scanf( "%s",&str)== 1 && strcmp( str, zubat) ==0 )  /* If the two strings are equal, strcmp returns 0 */
76.           {
77.           if ( p <= 0)
78.            {
79.           printf( "No zubat pokemon to evolve \n");
80.           return 0;
81.            }
82.           if ( c < 50 )
83.           {
84.           printf( "Not enough zubat candies for evolution \n");
85.           return 0;
86.           }
87.
88.            if (p>c/50)  /* zubat */
89.             {
90.              printf( "Zubat \n");
91.              printf( "Amount of evolutions: %d \n", c/49);
92.              printf( "Amount of XP: %d \n", (c/49 *500)*2);
93.              printf( "Amount of zubats left: %d \n", p- c/49);
94.              printf( "Amount of candies left: %d \n", c -(c/49)*49);
95.             }
96.            else if (p<=c/50)
97.             {
98.
99.              printf( "Zubat \n");
100.              printf( "Amount of evolutions: %d \n", p );
101.              printf( "Amount of XP: %d \n", ( p * 500)*2);
102.              printf( "Amount of zubats left: %d \n", (p - c/50)-c/50 >=0);
103.              printf( "Amount of candies left: %d \n", c -  p*50 + p); /* +p because you get 1 candy back for each evolution */
104.             }
105.              return 0;
106.             }
107.
108.
109.
110.
111. if (p>c/12)  /* pidgey */
112.  {
113.  printf( "Pidgey \n");
114.  printf( "Amount of evolutions: %d \n", c/11);
115.  printf( "Amount of XP: %d \n", (c/11 *500)*2);
116.  printf( "Amount of pidgeys left: %d \n", p- c/11);
117.  printf( "Amount of candies left: %d \n", c -(c/11)*11);
118.  }
119. else if (p<=c/12)
120. {
121.  printf( "Pidgey \n");
122.  printf( "Amount of evolutions: %d \n", p );
123.  printf( "Amount of XP: %d \n", ( p * 500)*2);
124.  printf( "Amount of pidgeys left: %d \n", (p - c/12)-c/12 >=0);
125.  printf( "Amount of candies left: %d \n", c -  p*12 + p); /* +p because you get 1 candy back for each evolution */
126. }
127.
128. }