第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

急!關(guān)于c++編日歷的問(wèn)題,大佬幫忙看看

急!關(guān)于c++編日歷的問(wèn)題,大佬幫忙看看

C++
逝月兮 2017-06-22 19:09:21
#include<iostream>#include<iomanip>using namespace std;class Calendar{public:int weekday;int year;public://Calendar(){};void printmonthdays();void printtitle(int m);int monthdays(int n);int firstday(int year);};int Calendar::monthdays(int m){ switch(m) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; case 4: case 6: case 9: case 11: return 30; case 2: if(((this->year%4==0&&this->year%100!=0)||this->year%400==0)) return 29; else return 28; default:return 0; }}void Calendar::printmonthdays(){ int days; for(int n=1;n<=12;n++) { printtitle(n); days=monthdays(n); for(int i=1;i<=days;i++) { cout<<setw(7)<<i; weekday=(weekday+1)%7;//星期 if(weekday==0) cout<<"\n"; } cout<<"\n"; }}void Calendar::printtitle(int m){ int i;? cout<<"\n"<<m<<"月 ?日 ? ? 一 ? ? 二 ? ? 三 ? ? 四 ? ? 五 ? ? 六 \n"; //cout<<" ";? for(i=0;i<weekday;i++) cout<<" ? ? ? ";}int Calendar::firstday(int year){ int a,b; a=year/100; b=year%100-1; return (b+(b/4)+(a/4)-2*a+(26*(13+1)/10))%7;}void main(int argc,char* argv[]){ int year; int weekday; Calendar cal; cout<<"請(qǐng)輸入你要查看的年份:"; cin>>year; weekday=cal.firstday(year); cout<<"\n\n"; cout<<" ? ? ? ? ? "<<year<<"年"; cal.printmonthdays(); cout<<"\n\n";}我找不到錯(cuò)誤,麻煩幫我分析下,謝謝
查看完整描述

1 回答

已采納
?
MR帽子先生

TA貢獻(xiàn)245條經(jīng)驗(yàn) 獲得超106個(gè)贊

switch(m)錯(cuò)了,括號(hào)里面內(nèi)容應(yīng)該轉(zhuǎn)為int類型不然是str類型的。

希望對(duì)你有幫助,祝您學(xué)習(xí)愉快,有幫助的話請(qǐng)采納我的答案。

查看完整回答
反對(duì) 回復(fù) 2017-06-24
  • 逝月兮
    逝月兮
    請(qǐng)問(wèn)具體怎么改呢
  • MR帽子先生
    MR帽子先生
    switch(int m) 直接轉(zhuǎn)換為int類型就可以了。祝你學(xué)習(xí)順利。
  • 逝月兮
    逝月兮
    抱歉,這幾天考試,沒(méi)來(lái)得及回復(fù)你。這樣改不對(duì)哦,需要在firstday(int year)函數(shù)這里,改為int Calendar::firstday(int year_input) { year=year_input; …… 但我不知道這是什么意思,in_put是啥啊
點(diǎn)擊展開(kāi)后面2
  • 1 回答
  • 0 關(guān)注
  • 1167 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)