求助cpp(126) : warning C4715: 'getMonthValue' : not all control paths return a val
程序代码:
问题在最后 //函数功能:根据输入的日期来判断输出的日期是星期几。 #include<iostream> bool isLeapYear(int year); int getCenturyValue(int year); int getYearVlaue(int year); int getMonthValue(int month, int year); void getInput( int m_m, int m_d, int m_y); int main() { using namespace std; int m_month=0,m_day=0,m_year=0,r_sum,r_r; getInput(m_month,m_day,m_year); r_sum=m_day+getMonthValue(m_month,m_year) +getYearVlaue(m_year)+getCenturyValue(m_year); r_r=r_sum%7; switch(r_r) { case 0: cout<<"Sunday"<<endl; break; case 1: cout<<"Monday"<<endl; break; case 2: cout<<"Tuesday"<<endl; break; case 3: cout<<"Wednesday"<<endl; break; case 4: cout<<"Thursday"<<endl; break; case 5: cout<<"Friday"<<endl; break; case 6: cout<<"Saturday"<<endl; break; } return 0; } //判断是否为闰年 bool isLeapYear(int year) { if( (year%400==0)||( (year%4==0)&&(year%100!=0) ) ) return true; else return false; } //获取年份头两位 int getCenturyValue(int year) { int q2_year,num; q2_year=year/100; num=(3-(q2_year%4))*2; return num; } int getYearVlaue(int year) { int r_year; r_year=(year%100)/4+(year%100); return r_year; } //按月份返回值 int getMonthValue(int month, int year) { if(month==1) { if( isLeapYear(year) ) { return 6; } else return 0; } if(month==2) { if( isLeapYear(year) ) { return 2; } else return 3; } if(month==3) { return 3; } if(month==4) { return 6; } if(month==5) { return 1; } if(month==6) { return 4; } if(month==7) { return 6; } if(month==8) { return 2; } if(month==9) { return 5; } if(month==10) { return 0; } if(month==11) { return 3; } if(month==12) { return 5; } } void getInput( int m_m, int m_d, int m_y) { using namespace std; cout<<"Please input month(number)"<<" "<<"days(number)" <<","<<" "<<"years"<<endl; cout<<"For instance:7 4,2008"<<endl; cin>>m_m>>m_d>>m_y; } G:\应用程序\判断星期\判断.cpp(126) : warning C4715: 'getMonthValue' : not all control paths return a value 谢谢
[ 本帖最后由 朱稳 于 2012-3-12 09:28 编辑 ]