欢迎来到天天文库
浏览记录
ID:40526317
大小:590.41 KB
页数:83页
时间:2019-08-04
《CC++数据结构一点经典题目》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Test2-4个人所得税的计算(if-else-if)#includeusingnamespacestd;//个人所得税的计算intmain(){floatincome,taxable,tax;cout<<"PleaseinputtheMonthlyIncome:";cin>>income;taxable=income-3500;if(taxable<=0)tax=0;elseif(taxable<=1500)tax=taxable*0.03;elseif(taxable<=4500)tax=taxable*0
2、.1-105;elseif(taxable<=9000)tax=taxable*0.2-555;elseif(taxable<=35000)tax=taxable*0.25-1005;elseif(taxable<=55000)tax=taxable*0.3-2755;elseif(taxable<=80000)tax=taxable*0.35-5505;elsetax=taxable*0.45-13505;cout<<"Taxlibilityis"<3、ase)1>算出year这一年元旦星期几2>根据mouth和day,计算该日期是year这一年的第几天#includeusingnamespacestd;//计算某天是星期几intmain(){intyear,mouth,day,week,d;cout<<"请按年月日的方式输入一个日期:"<>year>>mouth>>day;d=year+(year-1)/4-(year-1)/100+(year-1)/400;week=d%7;d=0;switch(mouth-1){case11:d+=34、0;case10:d+=31;case9:d+=30;case8:d+=31;case7:d+=31;case6:d+=30;case5:d+=31;case4:d+=30;case3:d+=31;case2:d+=28;if(year%4==0&&year%100!=05、6、year%400!=0)d++;//判断是否是闰年case1:d+=31;}d+=day;week=(week+(d-1)%7)%7;if(week==0)cout<7、cout<usingnamespacestd;//找最大数和最小数(循环)intmain(){intx,max,min;cout<<"请依次输入5个数(空格隔开):"<>x;//输入一个数max=min=x;for(inti=2;i<=5;i++)//循环从2开始{cin>>x;if(max8、x)min=x;}cout<<"最大值为MAX="<usingnamespacestd;intmain(){intsele,zhang,li,wang,nosele,other,num;zhang=li=wang=nosele=other=0;cin>>sele;while(sele!=-1){switch(sele){case1:zhang++;break;//当输入为19、时,为zhang投票case2:li++;break;//当输入为2时,为li投票case3:wang++;break;case0:nosele++;break;//弃权为0case4:other++;break;//无效票(选择人数超过一)default:cout<<"InputError!"<>sele;}num=zhang+li+wang+nosele+other;//请问弃权和无效的票算不算其中floatz,l,w;z=zhang/(float)num;l=li/(float)num;w=wang/(10、float)num;cout<<"zhang:"<
3、ase)1>算出year这一年元旦星期几2>根据mouth和day,计算该日期是year这一年的第几天#includeusingnamespacestd;//计算某天是星期几intmain(){intyear,mouth,day,week,d;cout<<"请按年月日的方式输入一个日期:"<>year>>mouth>>day;d=year+(year-1)/4-(year-1)/100+(year-1)/400;week=d%7;d=0;switch(mouth-1){case11:d+=3
4、0;case10:d+=31;case9:d+=30;case8:d+=31;case7:d+=31;case6:d+=30;case5:d+=31;case4:d+=30;case3:d+=31;case2:d+=28;if(year%4==0&&year%100!=0
5、
6、year%400!=0)d++;//判断是否是闰年case1:d+=31;}d+=day;week=(week+(d-1)%7)%7;if(week==0)cout<7、cout<usingnamespacestd;//找最大数和最小数(循环)intmain(){intx,max,min;cout<<"请依次输入5个数(空格隔开):"<>x;//输入一个数max=min=x;for(inti=2;i<=5;i++)//循环从2开始{cin>>x;if(max8、x)min=x;}cout<<"最大值为MAX="<usingnamespacestd;intmain(){intsele,zhang,li,wang,nosele,other,num;zhang=li=wang=nosele=other=0;cin>>sele;while(sele!=-1){switch(sele){case1:zhang++;break;//当输入为19、时,为zhang投票case2:li++;break;//当输入为2时,为li投票case3:wang++;break;case0:nosele++;break;//弃权为0case4:other++;break;//无效票(选择人数超过一)default:cout<<"InputError!"<>sele;}num=zhang+li+wang+nosele+other;//请问弃权和无效的票算不算其中floatz,l,w;z=zhang/(float)num;l=li/(float)num;w=wang/(10、float)num;cout<<"zhang:"<
7、cout<usingnamespacestd;//找最大数和最小数(循环)intmain(){intx,max,min;cout<<"请依次输入5个数(空格隔开):"<>x;//输入一个数max=min=x;for(inti=2;i<=5;i++)//循环从2开始{cin>>x;if(max
8、x)min=x;}cout<<"最大值为MAX="<usingnamespacestd;intmain(){intsele,zhang,li,wang,nosele,other,num;zhang=li=wang=nosele=other=0;cin>>sele;while(sele!=-1){switch(sele){case1:zhang++;break;//当输入为1
9、时,为zhang投票case2:li++;break;//当输入为2时,为li投票case3:wang++;break;case0:nosele++;break;//弃权为0case4:other++;break;//无效票(选择人数超过一)default:cout<<"InputError!"<>sele;}num=zhang+li+wang+nosele+other;//请问弃权和无效的票算不算其中floatz,l,w;z=zhang/(float)num;l=li/(float)num;w=wang/(
10、float)num;cout<<"zhang:"<
此文档下载收益归作者所有