您现在的位置是:首页 >综合 > 2023-08-05 10:24:07 来源:
什么叫非编系统(非编系统)
大家好,我是小华,我来为大家解答以上问题。什么叫非编系统,非编系统很多人还不知道,现在让我们一起来看看吧!
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; }。
本文到此讲解完毕了,希望对大家有帮助。