1樓:朝朝戰士邦
#include
//最笨的方法
int numpick()}}
return i;
}//第2題
//記錄每乙個月的天數
int m_nday[2][13]=,
};//判斷是否閏年
int isnonleapyear(int year)else if (year%4 == 0) return 1;
else return 0;
}//計算是哪一天
int getthedayofyear(int year, int month, int day)
daycount += day;
}else if(isnonleapyear(year) == 0)daycount += day;
}return daycount;
}//第3題
//假設他們近親結婚,然後從一而終啊
int howmanyrabbit(int month)
2樓:手機使用者
類的多型性和虛函式,**沒問題,你想問什麼
一道c++程式設計問題,求大神打出**,懸賞全給你
3樓:熱情的豆芽豆芽
寫了1個小時,哈哈哈哈,**僅供參考~需要注意這裡,0年1月1日為第一天,滿足題意「」將指定日期轉換成從0年o月o日起的天數「」,裡面有一些c ++11的特性(右值引用需要提前了解一下哈)~
#include
using namespace std;
class date;
int getyear()
int getmonth()
int getday()
date operator+(int days)
date operator-(int days)
else
}int operator-(date&b)
friend ostream& operator << (ostream &out, date &a)
friend ostream& operator << (ostream &out, date &&a)
protected:
bool leap(int year)
int dton(date &b)
else
sum += 365;
}bool flag = leap(b.m_year);
for (int i = 0; i < b.m_month - 1; i++)
sum += day_tab[flag][i];
sum += b.m_day;
return sum;
}date ntod(int day)
int i = 0;
bool flag = leap(year);
int monthday = 0;
for (i = 0; i < 12 && monthday <= day; i++)
monthday -= day_tab[flag][i - 1];
i--;
date *a = null;
if(day -monthday !=0)
a = new date(year, i + 1, day - monthday);
else
return *a;
}int day_tab[2][12] = ,
};private:
int m_year;
int m_month;
int m_day;
};int main(){
date a(0, 12, 31);
cout << a << endl;
cout << a + 1 << endl;
date b = a-2;
cout<
c++程式設計題(需要完整**)~求大神
4樓:忽忽上公升
#include
using namespace std;
class vehicle
請求解答C 程式設計題目,謝謝啊,C 程式設計問題,急求答案,謝謝啦,一共有三題,請求幫忙啊 最需要第一題的答案
include include template void sum const t t1,const t t2,t sum,int t1len,int t2len else int main int b 5 int c 5 sum a,b,c,2,5 for index 0 index 5 inde...
c 請高手來解答急求,急求C 程式設計高手解決問題,謝謝
改好了,自己對照 include include class p int inc1 int inc2 void display private int pri1,pri2 class d1 virtual private pint inc1 int inc3 void display private...
c語言問題求大神解答,C語言問題求大神解答
我看了樓上的追問,說實話,不知道樓主在問什麼。我就說下if else處的思想吧。1 假設有個輸入是有一連串空格符號的,那程式就只會進入。if c c n c t state out 不會計數。2 假設我現在剛開始輸入第乙個字母。if c c n c t state out 這裡進不去了,進去了 el...
c語言問題求大神解答,C語言問題求大神解答。。
現在要求你在不打亂原來順序的基礎上插入一部分資料 刪除一部分資料,並輸出 看了你的 有乙個排序的過程 但是原題要求是不打亂原來的資料 沒有問題啊 include include int main s scanf d a t t while 1 s scanf d a t t while 1 else...
求高手指點C語言程式設計,具體問題要求如下
如果到晚上還沒人寫我就幫你寫 c語言程式設計,求5個學生5門課的平均成績,求高手指點,謝謝,萬分感激 兩層for迴圈的執行順序 其實對於兩層for迴圈,可以拆成多個一層的for迴圈。如上就可以拆成如下的for迴圈 for j 0 j 5 j sum sum s 0 j s 0 5 sum 5 for...