1.
#include <iostream>
using namespace std;
int main()
{
enum types{A,B,C}type;
type=C;
switch(type)
{
case(A):
{
cout<<"you selected FREEDOM GUNDAM"<<endl;
}
case(B):
{
cout<<"you selected JUSTICE GUNDAM"<<endl;
}
case(C):
{
cout<<"you eslected IMPUSE GUNDAM"<<endl;
}
}
return 0;
}
结果:you selected IMPUSE GUNDAM
2.
#include<iostream>
using namespace std;
enum weapons
{
Flame_Sword=1,
YAMATO,
BBguns,
Cyclone_Blade,
RPG
};
int main()
{
weapons A=YAMATO;
if(A==2)
{
cout<<"Weapons has been equiped"<<endl;
}
else
{
cout<<"No enough mineral"<<endl;
}
return 0;
}
结果 Weapons has been equiped。