C++大神过来!!!?
雨花石1682015 2021-09-06 19:33 按你的程序,修正了你的疏忽,程序可以编译运行了,运行例如下:修改后的程序如下:#include<iostream>using namespace std;int main(){int month,day;cout<<"请输入你的出生月份和出生日,比如:1 1,(月份在前,日在后,中间要有空格)。"<<endl;cout<<"这样就可以测出你的星座了!"<<endl;cin>>month>>day;if(month==3){if(day>=21&&day<=31){cout<<"白羊座"; }else if(day>=1&&day<=20){cout<<"双鱼座"; }else{cout<<"此月没有这一天哟!"; }}else if(month==4){if(day>=20&&day<=30){cout<<"金牛座";}else if(day>=1&&day<=19){cout<<"白羊座"; }else{cout<<"此月没有这一天哟!"; }}else if(month==5){if(day>=21&&开发者_开发问答day<=31){cout<<"双子座"; }else if(day<=20&&day>=1){cout<<"金牛座"; }else{cout<<"此月没有这一天哟!"; }}else if(month==6){if(day>=22&&day<=30){cout<<"巨蟹座"; }else if(day<=21&&day>=1){cout<<"双子座"; }else{cout<<"此月没有这一天哟!"; }}else if(month==7){if(day>=23&&day<=31){cout<<"狮子座";}else if(day<=22&&day>=1){cout<<"巨蟹座";}else{cout<<"此月没有这一天哟!"; }}else if(month==8){if(day>=23&&day<=31){cout<<"处女座"; }else if(day<=22&&day>=1){cout<<"狮子座"; }else{cout<<"此月没有这一天哟"; }}else if(month==9){if(day>=23&&day<=30){cout<<"天秤座";}else if(day<=22&&day>=1){cout<<"处女座";}else{cout<<"此月没有这一天哟!"; }}else if(month==10){if(day>=24&&day<=31){cout<<"天蝎座";}else if(day<=23&&day>=1){cout<<"天秤座"; }else{cout<<"此月没有这一天哟!";}} else if(month==11){if(day>=23&&day<=30){cout<<"射手座";}else if(day<=22&&day>=1){cout<<"天蝎座"; }else{cout<<"此月没有这一天哟!"; }}else if(month==12){if(day>=22&&day<=31){cout<<"摩羯座";}else if(day<=21&&day>=1){cout<<"射手座";}else{cout<<"此月没有这一天哟!"; }}else if(month==1){if(day>=20&&day<=31){cout<<"水瓶座";}else if(day<=19&&day>=1){cout<<"摩羯座"; }else{cout<<"此月没有这一天哟!"; }}else if(month==2){if(day>=19&&day<=29){cout<<"双鱼座"; }else if(day<=18&&day>=1){cout<<"水瓶座";}else{cout<<"此月没有这一天哟!"; }} return 0;}主要是修改后面的 else (month==2){改为:else if(month==2){
精彩评论