欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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;

}

相关标签: c++ base c++