20150721输入年号,判断干支纪年和生肖

 #include<iostream>
using namespace std;
int main()
{
int a,b,c,year;
cout<<"请输入需要判断的年号:";
cin>>year;
cout<<endl;
a=(year%10+7);if(a>10)a=(a-10);
c=b=(year%12+9);if(b>12)c=b=(b-12);
cout<<"您输入的年号是";
switch(a)
{
case 1:cout<<"甲";break;
case 2:cout<<"乙";break;
case 3:cout<<"丙";break;
case 4:cout<<"丁";break;
case 5:cout<<"戊";break;
case 6:cout<<"己";break;
case 7:cout<<"庚";break;
case 8:cout<<"辛";break;
case 9:cout<<"壬";break;
case 10:cout<<"癸";break;
default:;break;
}
switch(b)
{
case 1:cout<<"子";break;
case 2:cout<<"丑";break;
case 3:cout<<"寅";break;
case 4:cout<<"卯";break;
case 5:cout<<"辰";break;
case 6:cout<<"巳";break;
case 7:cout<<"午";break;
case 8:cout<<"未";break;
case 9:cout<<"申";break;
case 10:cout<<"酉";break;
case 11:cout<<"戌";break;
case 12:cout<<"亥";break;
default:;break;
}
cout<<"年,生肖是";
switch(c)
{
case 1:cout<<"鼠";break;
case 2:cout<<"牛";break;
case 3:cout<<"虎";break;
case 4:cout<<"兔";break;
case 5:cout<<"龙";break;
case 6:cout<<"蛇";break;
case 7:cout<<"马";break;
case 8:cout<<"羊";break;
case 9:cout<<"猴";break;
case 10:cout<<"鸡";break;
case 11:cout<<"狗";break;
case 12:cout<<"猪";break;
default:;break;
}
cout<<"年。";
system("pause"); 
return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值