C++编写输入年月查询生肖以及星座

2022-10-15 19:21:08   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《C++编写输入年月查询生肖以及星座》,欢迎阅读!
C++,生肖,编写,年月,输入

#include <iostream>

#include <string>

using namespace std;

int main ()

{

int year,month,day;

cout<<"请输入年月日:";

cin>>year>>month>>day;

string sx[12]={"猴","鸡","狗","猪","鼠","牛","虎","兔","龙","蛇","马","羊"};

cout<<"你属"<<sx[year%12]<<endl;

switch(month) {

case 1 :if(day <= 20)

cout<<"你是魔羯座"<<endl;

else cout<<"你是水瓶座"<<endl;

break;

case 2 :if(day <= 19)

cout<<"你是水瓶座"<<endl;

else cout<<"你是双鱼座"<<endl;

break;

case 3 :if(day <= 20)

cout<<"你是双鱼座"<<endl;

else cout<<"你是白羊座"<<endl;

break;

case 4 :if(day <= 20)

cout<<"你是白羊座"<<endl;

else cout<<"你是金牛座"<<endl;

break;

case 5 :if(day <= 21)

cout<<"你是金牛座"<<endl;

else cout<<"你是双子座"<<endl;

break;

case 6 :if(day <= 21)

cout<<"你是双子座"<<endl;

else cout<<"你是巨蟹座"<<endl;

break;

case 7 :if(day <= 22)

cout<<"你是巨蟹座"<<endl;

else cout<<"你是狮子座"<<endl;

break;

case 8 :if(day <= 23)

cout<<"你是狮子座"<<endl;

else cout<<"你是处女座"<<endl;

break;

case 9 :if(day <= 23)

cout<<"你是处女座"<<endl;

else cout<<"你是天秤座"<<endl;

break;

case 10:if(day <= 23)

cout<<"你是天秤座"<<endl;

else cout<<"你是天蝎座"<<endl;

break;

case 11:if(day <= 22)

cout<<"你是天蝎座"<<endl;

else cout<<"你是射手座"<<endl;

break;

case 12:if(day <= 21)

cout<<"你是射手座"<<endl;

else cout<<"你是魔羯座"<<endl;

break;

}

}

本文来源:https://www.wddqxz.cn/251c9e22753231126edb6f1aff00bed5b9f373ad.html

相关推荐