1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include <iostream>
using namespace std;
struct Pokemon{
char FirstInitial;
int HP;
int Attack;
int Defense;
int SpAttack;
int SpDefense;
int Speed;
int totalStats(){
return (HP+Attack+Defense+SpAttack+SpDefense+Speed);
}
};
int main()
{
int greatestPokemon=0, greatestStats=0;
Pokemon allPokemon[] =
{
{'C',39,52,43,60,50,65}, // Charmander
{'P',40,45,40,35,35,56}, // Pidgey
{'T',50,64,64,44,48,43}, // Totodile
{'H',45,50,45,115,55,95}, // Haunter
{'A',25,20,15,105,56,90}, // Abra
{'M',20,10,55,15,20,80} // Magikarp
};
for(int i=0;i<6;++i){
if(allPokemon[i].totalStats()>greatestStats){
greatestPokemon=i;
greatestStats=allPokemon[i].totalStats();
}
}
cout<<allPokemon[greatestPokemon].FirstInitial<<" has the greatest stats of: "<<greatestStats<<endl;
cout<<"\nConsole Exit - Press <enter>: ";
cin.get();
return 0;
}
|