If else
程序员文章站
2024-01-07 08:50:40
...
/*
Defination: Try if else structure.
Author: Peng
*/
#include
using namespace std;
int main()
{
int choose=1;
cout << “Please choose your gender: \n” << " Male: free \t Female: 50 coin" << endl;
cout << “ch:” << choose<<endl;
cin >> choose;
cout << "ch:" << choose<<endl;
// a=1 means give the number 1 to a, but the a==1 means judge whether a equal 1
if (choose== 1)
{
cout << "ch:" << choose << endl;
cout << "Male" << endl;
}
else if( choose== 2)
{
cout << "Female" << endl;
}
else
{
cout << "Illegal character!"<<endl;
}
system("Pause");
return 0;
}