• 您現在的位置是:首頁 >綜合 > 2023-08-05 10:24:07 來源:

    什么叫非編系統(非編系統)

    導讀 大家好,我是小華,我來為大家解答以上問題。什么叫非編系統,非編系統很多人還不知道,現在讓我們一起來看看吧!1、因為涉及到怎么置光標...

    大家好,我是小華,我來為大家解答以上問題。什么叫非編系統,非編系統很多人還不知道,現在讓我們一起來看看吧!

    1、因為涉及到怎么置光標位置的問題,現在還做不出來,下面的程序是c++的。

    2、你看一下他是輸入粘合月求一個月的日歷,我再用C試一下 //輸入年月求該月日歷 #include #include using namespace std; class calendarType { private: int year; int month; int days; public: calendarType(int Year = 1500, int Month = 1); void setYear(int Year); void setMonth(int Month); int getYear(); int getMonth(); int getDays(int Year, int Month); bool IsLeapYear(int Year); void disCalendar(int Year, int Month); }; calendarType::calendarType(int Year, int Month) { if (Year < 1500 || Year > 3000) year = 1500; else year = Year; if (Month > 12 || Month < 1) month = 1; else month = Month; getDays(year, month); } void calendarType::setYear(int Year) { if (Year >= 1500 && Year <= 3000) year = Year; } void calendarType::setMonth(int Month) { if (Month >=1 && Month <= 12) month = Month; } inline int calendarType::getYear() { return year; } inline int calendarType::getMonth() { return month; } int calendarType::getDays(int Year, int Month) { switch(Month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days = 31;break; case 4: case 6: case 9: case 11: days = 30; break; case 2: if (IsLeapYear(Year)) days = 29; else days = 28; } return days; } //判斷閏年 bool calendarType::IsLeapYear(int Year) { if ((Year % 4 == 0 && Year % 100 != 0) || Year % 400 == 0) return true; else return false; } //輸出函數 void calendarType::disCalendar(int Year, int Month) { int totalDays = 0; for (int i = 1500; i < Year; i++) { if (IsLeapYear(i)) totalDays += 366; else totalDays += 365; } for (i = 1; i < Month; i++) { totalDays += getDays(Year, i); } totalDays++; int week = totalDays % 7; cout << setw(30) << Year << "年" << Month << "月"; cout << endl; cout << setw(8) << "Sun"; cout << setw(8) << "Mon"; cout << setw(8) << "Tue"; cout << setw(8) << "Wed"; cout << setw(8) << "Thu"; cout << setw(8) << "Fri"; cout << setw(8) << "Sat"; cout << endl; week++; if (week > 7) week = 1; for (i = 1; i < week; i++) cout << setw(8) << ""; getDays(Year, Month); for (i = 1; i <= days; i++) { if (week > 7) {cout << endl; week = 1; } cout << setw(8) << i; week++; } } //主函數 int main() { int year, month; cout << "輸入需要查詢的年和月:"; cout << flush; cin >> year >> month; calendarType Cal(year, month); Cal.disCalendar(year, month); getchar(); getchar(); return 0; }。

    本文到此講解完畢了,希望對大家有幫助。

  • 成人app