From 089bcc92a1da9dbb427337f68d3a03228885d100 Mon Sep 17 00:00:00 2001 From: lixworth Date: Sat, 7 Dec 2024 16:23:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- lcm.c | 350 +++++ lix.cpp | 274 ++++ stu2024/数技2401严一顺(有问题改不动了).cpp | 264 ++++ stu2024/数技2401田林(3).cpp | 635 ++++++++ stu2024/数技2401赵仔航.c | 315 ++++ stu2024/数技2402季界通.cpp | 359 +++++ stu2024/数技2402张一寒.cpp | 393 +++++ stu2024/数技2402张韵轩.cpp | 353 +++++ stu2024/数技2402张馨予.cpp | 202 +++ stu2024/数技2402樊璐瑶.cpp | 349 +++++ stu2024/数技2402赵思雨(1).cpp | 460 ++++++ stu2024/数科2401易诗雅.c | 236 +++ stu2024/数科2401谢诗涵.c | 150 ++ stu2024/网络2401郑世凯_02.cpp | 150 ++ stu2024/网络2401鹿逸翔.cpp | 231 +++ stu2024/网络2402崔依晨.cpp | 219 +++ stu2024/网络2402朱治雨.c | 51 + stu2024/虚拟2401刘军保(1).c | 192 +++ stu2024/虚拟2401张博文.c | 123 ++ stu2024/虚拟2401彭子杰.c | 164 +++ stu2024/虚拟2401房靖皓.cpp | 160 ++ stu2024/虚拟2401才忠鑫(1).cpp | 259 ++++ stu2024/虚拟2401杨博深.c | 202 +++ stu2024/虚拟2402周丛笑.c | 211 +++ stu2024/虚拟2402康诗曼(1).c | 173 +++ stu2024/计科2401侯维.cpp | 389 +++++ stu2024/计科2401孙美琪.c | 368 +++++ stu2024/计科2401常迦鑫.cpp | 601 ++++++++ stu2024/计科2401王需.cpp | 272 ++++ stu2024/计科2401高在毅(1).cpp | 1380 ++++++++++++++++++ stu2024/计科2402 胡深然.cpp | 454 ++++++ stu2024/计科2402刘相宁.cpp | 326 +++++ stu2024/计科2402吕伟焘.cpp | 254 ++++ stu2024/计科2402沈意佳.cpp | 183 +++ stu2024/计科2402王娅晗.cpp | 249 ++++ stu2024/软件2401丁翔宇.cpp | 96 ++ stu2024/软件2401毕洺瑞.cpp | 186 +++ stu2024/软件2401范慈惠.cpp | 195 +++ stu2024/软件2401邱毅杰.cpp | 147 ++ stu2024/软件2401陈思宇(1).cpp | 384 +++++ stu2024/软件2402吕亦杰.c | 699 +++++++++ stu2024/软件2402唐凯杰.cpp | 342 +++++ stu2024/软件2402田世涛.cpp | 125 ++ stu2024/软件2403王琬琳.cpp | 171 +++ stu2024/软件2404李建瑞 第二次.cpp | 565 +++++++ stu2024/软件2404潘仕博.cpp | 143 ++ stu2024/软件2404王莫涵(1).cpp | 382 +++++ stu2024/软件2404班钟浩峻.cpp | 157 ++ stu2024/软件2404纪新峰.cpp.cpp | 218 +++ stu2024/软件工程2403张灿冉(1).cpp | 106 ++ yyw.cpp | 303 ++++ 52 files changed, 15173 insertions(+), 1 deletion(-) create mode 100644 lcm.c create mode 100644 lix.cpp create mode 100644 stu2024/数技2401严一顺(有问题改不动了).cpp create mode 100644 stu2024/数技2401田林(3).cpp create mode 100644 stu2024/数技2401赵仔航.c create mode 100644 stu2024/数技2402季界通.cpp create mode 100644 stu2024/数技2402张一寒.cpp create mode 100644 stu2024/数技2402张韵轩.cpp create mode 100644 stu2024/数技2402张馨予.cpp create mode 100644 stu2024/数技2402樊璐瑶.cpp create mode 100644 stu2024/数技2402赵思雨(1).cpp create mode 100644 stu2024/数科2401易诗雅.c create mode 100644 stu2024/数科2401谢诗涵.c create mode 100644 stu2024/网络2401郑世凯_02.cpp create mode 100644 stu2024/网络2401鹿逸翔.cpp create mode 100644 stu2024/网络2402崔依晨.cpp create mode 100644 stu2024/网络2402朱治雨.c create mode 100644 stu2024/虚拟2401刘军保(1).c create mode 100644 stu2024/虚拟2401张博文.c create mode 100644 stu2024/虚拟2401彭子杰.c create mode 100644 stu2024/虚拟2401房靖皓.cpp create mode 100644 stu2024/虚拟2401才忠鑫(1).cpp create mode 100644 stu2024/虚拟2401杨博深.c create mode 100644 stu2024/虚拟2402周丛笑.c create mode 100644 stu2024/虚拟2402康诗曼(1).c create mode 100644 stu2024/计科2401侯维.cpp create mode 100644 stu2024/计科2401孙美琪.c create mode 100644 stu2024/计科2401常迦鑫.cpp create mode 100644 stu2024/计科2401王需.cpp create mode 100644 stu2024/计科2401高在毅(1).cpp create mode 100644 stu2024/计科2402 胡深然.cpp create mode 100644 stu2024/计科2402刘相宁.cpp create mode 100644 stu2024/计科2402吕伟焘.cpp create mode 100644 stu2024/计科2402沈意佳.cpp create mode 100644 stu2024/计科2402王娅晗.cpp create mode 100644 stu2024/软件2401丁翔宇.cpp create mode 100644 stu2024/软件2401毕洺瑞.cpp create mode 100644 stu2024/软件2401范慈惠.cpp create mode 100644 stu2024/软件2401邱毅杰.cpp create mode 100644 stu2024/软件2401陈思宇(1).cpp create mode 100644 stu2024/软件2402吕亦杰.c create mode 100644 stu2024/软件2402唐凯杰.cpp create mode 100644 stu2024/软件2402田世涛.cpp create mode 100644 stu2024/软件2403王琬琳.cpp create mode 100644 stu2024/软件2404李建瑞 第二次.cpp create mode 100644 stu2024/软件2404潘仕博.cpp create mode 100644 stu2024/软件2404王莫涵(1).cpp create mode 100644 stu2024/软件2404班钟浩峻.cpp create mode 100644 stu2024/软件2404纪新峰.cpp.cpp create mode 100644 stu2024/软件工程2403张灿冉(1).cpp create mode 100644 yyw.cpp diff --git a/README.md b/README.md index ac4f227..2ea0379 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # UIT2024 项目考核 万年历 +文件夹下已存放UIT2023的部分日历代码,`stu_2024` 下存放的均是2024级所有人的代码。 +由于环境不同,代码仅供参考! + ### 考核要求 制作使用 C/C++ 编写一个命令行应用 万年历,有如下功能: @@ -15,4 +18,3 @@ 截止日期:2024年11月17日(周日) 注意事项:**原则上禁止代码抄袭,我们将参考程序实际运行情况与代码内容进行提问!** - diff --git a/lcm.c b/lcm.c new file mode 100644 index 0000000..1cb22c1 --- /dev/null +++ b/lcm.c @@ -0,0 +1,350 @@ +#define _CRT_SECURE_NO_WARNINGS +#pragma warning(disable:6031) +#include +#include +void one(int year);//ѯӦݵҪ˫ɵ +void two(int year, int month, int day);//ѯӦڵ +void three(int year);//ѯӦǷΪ +int main() { + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ\n"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n"); + int a; + int year, month, day; + while (scanf("%d", &a) != EOF) { + system("cls"); + if (a == 1) { + printf("ݣ"); + while (scanf("%d", &year) != EOF) { + system("cls"); + if (year > 0) { + one(year); + break; + } + else { + printf("룺"); + } + } + } + else if (a == 2) { + printf("ڣ գ"); + while (scanf("%d %d %d", &year, &month, &day) != EOF) { + system("cls"); + if (year > 0 && month > 0 && month < 13) { + if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { + if (day > 0 && day <= 31) { + two(year, month, day); + break; + } + else + printf("ڣ գ"); + } + else if (month == 4 || month == 6 || month == 9 || month == 11) { + if (day > 0 && day <= 30) { + two(year, month, day); + break; + } + else + printf("ڣ գ"); + } + else if (month == 2) { + if (!(year % 4) && (year % 100)) { + if (day > 0 && day <= 29) { + two(year, month, day); + break; + } + else + printf("ڣ գ"); + } + else { + if (day > 0 && day <= 28) { + two(year, month, day); + break; + } + else + printf("ڣ գ"); + } + } + } + else { + printf("ڣ գ"); + } + } + } + else if (a == 3) { + printf("ݣ"); + while (scanf("%d", &year) != EOF) { + system("cls"); + if (year > 0) { + three(year); + break; + } + else { + printf("룺"); + } + } + } + else if (a == 4) { + return 0; + } + else { + printf(":"); + } + } +} +void one(int year) { + int a[13] = { 0,31,0,31,30,31,30,31,31,30,31,30,31 }; + if (!(year % 4) && (year % 100)) { + a[2] = 29; + } + else { + a[2] = 28; + } + int g = ((year - 1) * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; + g++; + printf("1.\n"); + printf("2.˫\n"); + int q; + while (scanf("%d", &q) != EOF) { + system("cls"); + if (q == 1 || q == 2) { + break; + } + else { + printf("룺"); + } + } + if (q == 1) { + if (year != 1582) { + if (year < 1582) + g += 5; + if (g >= 7) + g %= 7; + + printf("\n%d\n", year); + int m = 1; + while (m <= 12) { + printf("\n%d\n", m); + printf("\tһ\tڶ\t\t\t\t\n"); + for (int j = 0, k = 1;k <= a[m];j) { + if (j == g) { + g++; + j++; + printf("%d\t", k++); + if (j == 7) { + j = 0; + g = 0; + printf("\n"); + } + } + else { + j++; + printf("\t"); + } + } + printf("\n"); + m++; + } + } + else { + printf("\n%d", year); + int m = 1; + while (m <= 12) { + printf("\n%d\n", m); + printf("\tһ\tڶ\t\t\t\t\n"); + for (int j = 0, k = 1;k <= a[m];j) { + if (j == g) { + g++; + j++; + if (m == 10 && k == 5) + k = 15; + printf("%d\t", k++); + if (j == 7) { + j = 0; + g = 0; + printf("\n"); + } + } + else { + j++; + printf(" \t"); + } + } + printf("\n"); + m++; + } + } + } + else { + if (year < 1582) { + g += 5; + } + if (g >= 7) { + g %= 7; + } + int f = (g + 31) % 7; + int y = f; + printf("%d\n", year); + int m = 1; + while (m <= 12) { + int n = m + 1; + printf("%d\t\t\t\t\t\t\t\t%d\n", m, n); + printf("\tһ\tڶ\t\t\t\t\t\t\tһ\tڶ\t\t\t\t\n"); + int i = 1, j = 1; + for (i = 1, j = 1;i <= a[m] || j <= a[n];i, j) { + for (int k = 0;1;k) { + if (k == g) { + k++, g++; + if (i <= a[m]) + printf("%d\t", i++); + else + printf("\t"); + if (k == 7) { + k = 0, g = 0; + break; + } + } + else { + printf("\t"); + k++; + } + } + printf("\t"); + for (int k = 0;1;k) { + if (k == f) { + k++, f++; + if (year == 1582 && n == 10 && j == 5) { + j = 15; + } + if (j <= a[n]) + printf("%d\t", j++); + else + printf("\t"); + if (k == 7) { + k = 0, f = 0; + break; + } + } + else { + printf("\t"); + k++; + } + } + printf("\n"); + } + if (year == 1582 && m == 9) { + g = (y + a[n] - 10) % 7; + f = (g + a[n + 1]) % 7; + y = f; + } + else { + g = (y + a[n]) % 7; + f = (g + a[n + 1]) % 7; + y = f; + } + m += 2; + } + } + system("pause"); + system("cls"); + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ\n"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n"); + printf("\n\nҪеIJ"); +} +void two(int year, int month, int day) { + char n[7]; + char a[7]; + int g, i, k, r = 0; + g = ((year - 1) * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; + if (year != 1582) { + if (year < 1582) + g += 5; + if (g >= 7) + g %= 7; + } + if (year == 1582 && month == 10) { + if (day > 4 && day < 15) { + system("cls"); + printf("һЩԭ1582105յ15821014ʮ챻ɾȥ\n"); + system("Pause"); + system("cls"); + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ\n"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n"); + printf("\n\nҪеIJ"); + return ; + } + } + switch (0) + { + case 0:a[0] = 's'; + case 1:a[1] = 'm'; + case 2:a[2] = 't'; + case 3:a[3] = 'w'; + case 4:a[4] = 'x'; + case 5:a[5] = 'f'; + case 6:a[6] = 'a'; + } + for (i = 0, k = g;i < 7;i++, g++) + { + if (g == 7) + g = 0; + n[i] = a[g]; + } + switch (month - 1) + { + case 12:r += 31; + case 11:r += 30; + case 10:r += 31; + case 9:r += 30; + case 8:r += 31; + case 7:r += 31; + case 6:r += 30; + case 5:r += 31; + case 4:r += 30; + case 3:r += 31; + case 2:r += 28; + case 1:r += 31; + } + if (!(year % 4) && (year % 100) && (month > 2)) + r++; + r += day; + k = r % 7; + printf("%d%d%d", year, month, day); + switch (n[k]) + { + case 's':printf("\n");break; + case 'm':printf("һ\n");break; + case 't':printf("ڶ\n");break; + case 'w':printf("\n");break; + case 'x':printf("\n");break; + case 'f':printf("\n");break; + case 'a':printf("\n");break; + } + system("pause"); + system("cls"); + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ\n"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n"); + printf("\n\nҪеIJ"); +} +void three(int year) { + if ((year % 4 == 0) && (year % 100) != 0) { + printf("\n%d\n\n", year); + } + else { + printf("\n%d겻\n\n", year); + } + system("pause"); + system("cls"); + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ\n"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n"); + printf("ҪеIJ"); +} \ No newline at end of file diff --git a/lix.cpp b/lix.cpp new file mode 100644 index 0000000..a3195aa --- /dev/null +++ b/lix.cpp @@ -0,0 +1,274 @@ +// +// Created by Worth Lix on 2023/11/26 19:13. +// +#include +#include +#include +#include +#include + +using namespace std; + +#define RESET "\033[0m" +#define RED "\033[31m" +#define GREEN "\033[32m" +#define YELLOW "\033[33m" + +#define INFO (std::cout << RESET) +#define WARN (std::cout << YELLOW) +#define ERROR (std::cout << RED) +#define SUCCESS (std::cout << GREEN) +#define LOG_CLEAR (std::cout << "\033c") + +vector stringStream; + +int get_week(int y, int m, int d) { + if (m == 1 || m == 2) { + m += 12; + y--; + } + return ((d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7) + 1; +} +int check_leap_year(int year) { return (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)); } +int get_month_days_count(int year, int month) { + // 1 3 5 7 8 10 12 + if (month == 2) { + if (check_leap_year(year)) { + return 29; + } else { + return 28; + } + } + int day31[] = {1, 3, 5, 7, 8, 10, 12}; + for (int i = 0; i <= 6; ++i) { + if (day31[i] == month) { + return 31; + } + } + return 30; +} + +void menu() { + LOG_CLEAR; + time_t now = time(0); + struct tm *local = localtime(&now); + + printf("现在的时间是: %d/%02d/%02d %02d:%02d:%02d\n\n菜单:\n", 1900 + local->tm_year, 1 + local->tm_mon, + local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec); + WARN << "1.查询对应年份的日历" << endl; + WARN << "2.查询对应日期的星期" << endl; + WARN << "3.查询对应年份是否为闰年" << endl; + WARN << "4.退出" << endl; + + INFO << endl << "请输入菜单编号(1-4): "; +} + +void query_year() { + cout << "请输入要查询的年份:" << endl; + int query; + cin >> query; + LOG_CLEAR; + + cout << "请选择想要输出的日历格式:" << endl; + cout << "1.竖向输出:" << endl; + cout << "2.2*6格式横向输出:" << endl; + + int input; + cin >> input; + string cache; + + string echo_month[100][100] = {}; + int echo_month_line; + + switch (input) { + case 1: + LOG_CLEAR; + if (query == 1582) { + ERROR << "不支持该年份的查询! 震惊派蒙一整年.jpg" << endl; + break; + } + SUCCESS << "====================== " << query << "年 ======================" << endl; + for (int i = 1; i <= 12; ++i) { + cout << RED << i << "月" << endl; + cout << RESET << "周日\t周一\t周二\t周三\t周四\t周五\t周六" << endl; + int start = get_week(query, i, 1); + if (start < 7) { + for (int j = 0; j < start; ++j) { cout << "\t"; } + } + for (int j = 1; j <= get_month_days_count(query, i); ++j) { + printf("%02d\t", j); + if (get_week(query, i, j) == 6) { + printf("\n"); + } + } + printf("\n\n"); + } + break; + case 2: + LOG_CLEAR; + if (query == 1582) { + ERROR << "不支持该年份的查询! 震惊派蒙一整年.jpg" << endl; + break; + } + SUCCESS << "====================== " << query << "年 ======================" << endl; + for (int i = 1; i < 12; i = i + 2) { + cache += RED + to_string(i) + "月" + "\t\t\t\t\t\t\t\t" + to_string(i + 1) + "月"; + stringStream.push_back(cache); + cache.clear(); + cache = cache + RESET + "周日\t周一\t周二\t周三\t周四\t周五\t周六" + + "\t\t周日\t周一\t周二\t周三\t周四\t周五\t周六"; + stringStream.push_back(cache); + cache.clear(); + int start = get_week(query, i, 1); + if (start < 7) { + for (int j = 0; j < start; ++j) { cache += "\t"; } + } + echo_month_line = 0; + for (int j = 1; j <= get_month_days_count(query, i); ++j) { + if (j < 10) { + cache += to_string(0) + to_string(j) + "\t"; + } else { + cache += to_string(j) + "\t"; + } + if (get_week(query, i, j) == 6) { + echo_month[i][echo_month_line] = cache; + cache.clear(); + echo_month_line++; + } + if (j == get_month_days_count(query, i)) { + int week = get_week(query, i, j); + week = week == 7 ? 0 : week; + for (int k = 0; k < 7 - week; ++k) { + if (k == 7 - week - 1) { + cache + " "; + continue; + } + cache += " \t"; + } + echo_month[i][echo_month_line] = cache; + cache.clear(); + } + } + echo_month_line = 0; + start = get_week(query, i + 1, 1); + if (start < 7) { + for (int j = 0; j < start; ++j) { cache += "\t"; } + } + for (int j = 1; j <= get_month_days_count(query, i + 1); ++j) { + if (j < 10) { + cache += to_string(0) + to_string(j) + "\t"; + } else { + cache += to_string(j) + "\t"; + } + if (get_week(query, i + 1, j) == 6 || j == get_month_days_count(query, i + 1)) { + echo_month[i + 1][echo_month_line] = cache; + cache.clear(); + echo_month_line++; + } + } + cache.clear(); + + for (int j = 0; j < 6; ++j) { + if (echo_month[i][j] == "") { + cache = " \t \t \t \t \t \t \t\t" + echo_month[i + 1][j]; + } else { + cache = echo_month[i][j] + "\t" + echo_month[i + 1][j]; + } + + stringStream.push_back(cache); + + cache.clear(); + } + stringStream.push_back("\n"); + } + for (unsigned int i = 0; i < stringStream.size(); ++i) { cout << stringStream[i] << endl; } + stringStream.clear(); + break; + default: + cout << 123 << endl; + break; + } +} +void query_week() { + cout << "请输入要查询的日期: (年月日才用空格间隔)" << endl; + int y, m, d; + cin >> y >> m >> d; + if (y == 1582) { + ERROR << "不支持该年份的查询! 震惊派蒙一整年.jpg" << endl; + } else { + int week = get_week(y, m, d); + + switch (week) { + case 1: + SUCCESS << "周一" << endl; + break; + case 2: + SUCCESS << "周二" << endl; + break; + case 3: + SUCCESS << "周三" << endl; + break; + case 4: + SUCCESS << "周四" << endl; + break; + case 5: + SUCCESS << "周五" << endl; + break; + case 6: + SUCCESS << "周六" << endl; + break; + case 7: + SUCCESS << "周日" << endl; + break; + default: + break; + } + } +} +void query_leap_year() { + cout << "请输入要查询的年份:" << endl; + int year; + cin >> year; + + if (check_leap_year(year)) { + SUCCESS << "闰年" << endl; + } else { + SUCCESS << "平年" << endl; + } +} + +int main() { + system("chcp 65001"); + int run = 1; + while (run) { + menu(); + int command; + cin >> command; + + switch (command) { + case 1: + LOG_CLEAR; + query_year(); + system("pause"); + break; + case 2: + LOG_CLEAR; + query_week(); + system("pause"); + break; + case 3: + LOG_CLEAR; + query_leap_year(); + system("pause"); + break; + case 4: + run = 0; + break; + default: + ERROR << "菜单错误: 后面的区域请以后再探索吧!" << endl; + system("pause"); + break; + } + } + return 0; +} diff --git a/stu2024/数技2401严一顺(有问题改不动了).cpp b/stu2024/数技2401严一顺(有问题改不动了).cpp new file mode 100644 index 0000000..3a85695 --- /dev/null +++ b/stu2024/数技2401严一顺(有问题改不动了).cpp @@ -0,0 +1,264 @@ +#include "stdio.h" +/*ж*/ +int leap(int year) +{ + return ((year % 4 == 0 && year % 100!= 0) || year % 400 == 0); +} + +/*ȡijµ*/ +int ji_suan_tian_shu(int month, int year) +{ if(year==1582&&month==10) +{ + return 21; +} + if (month == 2) { + return leap(year)? 29 : 28; + } else if (month == 4 || month == 6 || month == 9 || month == 11) { + return 30; + } else { + return 31; + } +} + +/*11ڼ*/ +int ji_suan_di_yi_tian(int year) +{ + int K=year%100; + int J=year/100; + if(year<1582) + { + return (1+(13*(1+1))/5+K+K/4+5-J)%7; + + } + else + { + return (1+(13*(1+1))/5+K+K/4+J/4+5*J)%7; + + } + +} + + +/*ڵ*/ void xing_qi() +{ + printf(" һ \n"); +} +/*1582굥*/void chu_li_1582_nian_10_yue_de_ri_li(int *di_yi_tian) +{ + + + for (int i=0;i<*di_yi_tian;i++)//ǰӿո + { + printf(""); + } + + for (int day=1;day<=4;day++)//14 + { + printf("%5d",day); + if ((*di_yi_tian+day-1)%7==6)// + { + printf("\n"); + } + } + + + int x=5; + for (int day=15;day<=31;day++)//15ż֮ + { + if ((*di_yi_tian+x-1)%7==0)//һܻ + { + printf("\n"); + } + printf("%5d",day); + x++; + } + printf("\n"); + //*di_yi_tian=(*di_yi_tian+21)%7; +} +/*ijµ*/void shu_chu_yue_ri_li(int month, int year) { + int zhe_ge_yue_you_duo_shao_tian = ji_suan_tian_shu(month, year); + int zhe_ge_yue_di_yi_tian = ji_suan_di_yi_tian(year); + for (int i = 1; i < month; i++) //ijǰж + { + zhe_ge_yue_di_yi_tian+= ji_suan_tian_shu(i, year); + } + zhe_ge_yue_di_yi_tian%= 7;//ǰµһܼ + + xing_qi(); + + + /*ǰĿո*/for (int i = 0; i 4) + { + printf("1 2 3 4ѡ\n"); + }//if + + else if(x==1) + { + int year; + printf(":\t"); + scanf("%d",&year); + if((year%4==0&&year%100!=0)||year%400==0) + printf("\n"); + else + printf("ƽ\n"); + } + + + else if(x==2) + { + int year; + int month; + int day; + printf(" ʽΪ գ"); + scanf("%d %d %d",&year,&month,&day); + if(year==1582&&month==10&&day>4&&day<15); + printf("һ죬 ʽΪ գ\t"); + scanf("%d %d %d",&year,&month,&day); + const char *chu_chun_xing_qi[]={"","","һ","","","",""}; + int K=year%100; + int J=year/100; + int w; + if(year<1582||(year==1582&&(month<10||(month==10&&day<=4)))) + { + w=(day+(13*(month+1))/5+K+K/4+5-J)%7; + printf("һ%s\n",chu_chun_xing_qi[w]); + } + else + { + w=(day+(13*(month+1))/5+K+K/4+J/4+5*J)%7; + printf("һ%s\n",chu_chun_xing_qi[w]); + } + } + + else if(x==3) + { + int year; + printf(":\t"); + scanf("%d",&year); + printf("1 2ѡ\n1.\n2.˫\t"); + int c; + scanf("%d",&c); + if(c==1) + { + shu_chu_ri_li(year); + } + else if(c==2) + { + shu_chu_ri_li_2(year) ; + } + } + }//for + return 0; +} diff --git a/stu2024/数技2401田林(3).cpp b/stu2024/数技2401田林(3).cpp new file mode 100644 index 0000000..fa0356f --- /dev/null +++ b/stu2024/数技2401田林(3).cpp @@ -0,0 +1,635 @@ +#define _CRT_SECURE_NO_WARNINGS 1 +#include +#include +#include +#include +#include +using namespace std; +//1.չʾģ飬Ҫչʾ߱ +//2.ģ飬չʾ +//3.ģ飬ǷȷֹС +//4.{ҪչʾȽÿһź˳Σע1582 +//󣬽ڣʾΪɫ +// } +// ⣨ +// ָ⣨ +// +//5.չʾ +int mo1(void); +int mo2(int n); +void mo3(int n); +int mo4(void); +void mo5(int n); +void mo6(int n); +void aixin(void); +int zhanshi(void); +int dan1(int n); +void dan2(int n); +void xingqi(int aa); + +void color(short x) //Զ庯ݲıɫ +{ + if (x >= 0 && x <= 15)//0-15ķΧɫ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x); //ֻһıɫ + else//Ĭϵɫɫ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); +} + +int bao(int n) +{ + if (n > 1000000) { + cout << "Խ磬"< 4) { + cout << "" << endl; + return zhanshi(); + } + else + { + for (int i = 0; i < a.size(); i++) + { + if (a[i] < '0' || a[i]>'9') + { + cout << "" << endl; + return zhanshi(); + } + else + { + int p = a[i] - '0'; + p = pow(10, a.size() - i - 1) * p; + n += p; + } + } + return n; + } +} +int zhanshi(void) +{ + string n; + int i = 0; + int a = 0; + char b; + color(6); + cout << "Hello young people!!!" << endl; + cout << "------------------------------------------------------------------------------------------------------------------------" << endl; + cout << "------------------------------------------------------------------------------------------------------------------------" << endl; + cout << "------------------------------------------------------------------------------------------------------------------------" << endl; + cout << "This is a perpetual calendar!!!" << endl; + color(7); + cout << "кܶ๦" << endl; + color(3); + cout << "1.һڼ" << endl;// + cout << "2.Ƿһʺϱ׵" << endl;// + cout << "3.ij" << endl; + cout << "4.չʾijһ" << endl; + cout << "5.жijһǷΪ" << endl;// + color(12); + cout << "򵯳˵" << endl; + color(7); + cout << " Ҫķ" << endl; + do { + Sleep(100); + //scanf("%c", &n); + cin >> n; + //getchar(); + if (n.size() > 1) { + cout << "벻Ϲ淶" << endl; + return zhanshi(); + } + else { + b = n[0]; + if (b < 48 || b > 53) { + cout << "룡" << endl; + cout << "ǰ뻻" << endl; + i++; + } + if (i == 20) { + cout << "ˣ" << endl; + break; + + } + if (getchar() == '\n') { + a++; + + } + if (a > 5) return 0; + } + } while (b < 48 || b>53); + switch (b-'0') { + case 1: mo1(); break; + case 2: mo2(b); break; + case 3: mo6(b); break; + case 4: mo4(); break; + case 5: mo5(b); break; + default: return 0; + } + return 1; +} + +int mo1(void) +{ + int w; + string yy; + string mm; + string dd; + int ri[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; + int y, m, d; + cout << " " << endl; + cin >> yy; + y = zifu(yy); + cin >> mm; + m = zifu(mm); + cin >> dd; + d = zifu(dd); + if (y == 1582 && m == 10) { + if (d < 15 && d>4) { + cout << "" << endl; + return mo1(); + } + } + if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) { + ri[2] += 1; + } + if (y < 0 || y>10000 || m < 1 || m>12 || d < 1 || d > ri[m]) { + return mo1(); + } + if (y == 1582 && m == 10 && d > 4) { + + if (d > 4 && d < 15) { + cout << ""<> aa; + a=zifu(aa); + bao(a); + cin >> mm; + m = zifu(mm); + cin >> pp; + p = zifu(pp); + bao(m); + if (a % 4 == 0 && a % 100 != 0 || a % 400 == 0) { + ri[2] += 1; + } + if (m > 12 || m < 1) { + cout << "" << endl; + return mo2(m); + } + bao(p); + if (p > ri[m] || p < 1) { + cout << "" << endl; + return mo2(p); + } + if (m == 4 && p == 1) { + cout << "˽ڱף黻һ" << endl; + } + else if (m == 5 && p == 20 || p == 21) { + cout << "ףɹ" << endl; + aixin(); + } + else { + color(12); + cout << "ʲô֤뷨" << endl; + cout << "¸ҵʸ׷飬ףɹ" << endl; + return 0; + } + return 0; +} +int mo4(void) +{ + cout << "1 " << endl; + cout << "2 ˫" << endl; + string aa; + int a; + cin >> aa; + a = zifu(aa); + bao(a); + if (a > 2 || a < 1) { + cout << "ʧܣ" << endl; + } + switch (a) + { + case 1:dan1(a); break; + case 2:dan2(a); break; + default:return mo4(); break; + } + return 0; +} + +void mo5(int n) +{ + string aa; + int a; + cout << "" << endl; + cin >> aa; + a = zifu(aa); + /* n = 0; + if (a.size() > 4) return; + else + { + for (int i = 0; i < a.size(); i++) + { + if (a[i] < '0' || a[i]>'9') + { + return; + } + else + { + int p = a[i] - '0'; + p = pow(10, a.size() - i - 1) * p; + n+=p; + } + } + } + */ + if (n % 4 == 0 && n % 100 != 0 || n % 400 == 0) { + cout << "" << endl; + } + else cout << "" << endl; +} + +void mo6(int n) +{ + int d; + string yy; + string mm; + int y, m; + int w; + int t; + int j; + int ri[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; + + /* printf("_________________________________________\n"); + printf(" һ ܶ \n"); + printf("_________________________________________\n");*/ + //ж1Ϊܼ + //1֮ǰո + //scanf(%6d,&d); + //߾ͻУ + //1 + //231 + // + cout << " " << endl; + cin >> yy; + y = zifu(yy); + cin >> mm; + m = zifu(mm); + bao(y); + bao(m); + if (m > 12 || m < 1) { + return mo6(m); + } + if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) { + ri[2] += 1; + } + j = m; + if (m == 1 || m == 2) { + m += 12; + y--; + } + w = (1 + 1 + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7;// + printf("_________________________________________\n"); + printf(" һ ܶ \n"); + printf("_________________________________________\n"); + for (int i = 0; i < w; i++) { + cout << " "; + } + + t = w; + if (y == 1582 && m == 10) { + for (int i = 1; i <= 4; i++) { + if (t == 7) { + cout << endl; + t = 0; + } + printf("%5d", i); + t++; + } + for (int i=15; i <= ri[j]; i++) { + if (t == 7) { + cout << endl; + t = 0; + } + printf("%5d", i); + t++; + } + } + else { + for (int i = 1; i <= ri[j]; i++) { + if (t == 7) { + cout << endl; + t = 0; + } + printf("%5d", i); + t++; + } + } + return; +} + +void aixin(void) +{ + color(12); + float x, y, a; + for (y = 1.5f; y > -1; y -= 0.1f) { + for (x = -1.5f; x < 1.5f; x += .05f) { + a = x * x + y * y - 1; + putchar(a * a * a - x * x * y * y * y < 0.0f ? '*' : ' '); + } + Sleep(15); + putchar('\n'); + } + return; + +} + +int dan1(int n) +{ + int y, m, d; + string yy; + int w; + int t; + int ri[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; + cout << "" << endl; + //scanf("%d", &y); + cin >> yy; + y = zifu(yy); + bao(y); + for (int j = 1; j < 13; j++) { + if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) { + ri[2]++; + } + m = j; + if (m == 1 || m == 2) { + m += 12; + y--; + } + w = (1 + 1 + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7; + printf("_________________________________________\n"); + printf(" %d \n", j); + printf("_________________________________________\n"); + printf(" һ ܶ \n"); + printf("_________________________________________\n"); + for (int i = 0; i < w; i++) { + cout << " "; + } + + t = w; + if (y == 1582 && j == 10) { + for (int i = 1; i <= 4; i++) { + if (t == 7) { + cout << endl; + t = 0; + } + printf("%5d", i); + t++; + if (i == ri[j])cout << endl; + } + for (int i = 15; i <= ri[j]; i++) { + if (t == 7) { + cout << endl; + t = 0; + } + printf("%5d", i); + t++; + if (i == ri[j])cout << endl; + } + } + else { + for (int i = 1; i <= ri[j]; i++) { + if (t == 7) { + cout << endl; + t = 0; + } + printf("%5d", i); + t++; + if (i == ri[j])cout << endl; + } + ri[2] = 28; + if (m == 13 || m == 14) { + y++; + } + } + } + return 0; +} + +void xingqi(int aa) +{ + //int j = 1; + for (int i = 0; i < 2; i++) { + printf("_________________________________________\t"); + } + cout << "\n"; + for (int i = 0; i < 2; i++) { + printf(" %d \t", aa++); + } + cout << "\n"; + for (int i = 0; i < 2; i++) { + printf("_________________________________________\t"); + } + cout << "\n"; + for (int i = 0; i < 2; i++) { + printf(" һ ܶ \t\t"); + } + cout << "\n"; + for (int i = 0; i < 2; i++) { + printf("_________________________________________\t"); + } + cout << "\n"; + return; +} + +void dan2(int n) +{ + cout << ""; + cout << endl; + int y; + string yy; + cin >> yy; + y = zifu(yy); + bao(y); + ////////////// + int aa = 1; + int bb = 2; + ////////////// + int m = 1; + int a = 1; + int b = 1; + int c = 1; + int tt = 6; + int d = 35; + //int w; + int ri[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; + if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) { + ri[2]++; + } + int w;//һŵλô + int ww[13] = { 0 }; + int t[13] = { 0 }; + for (m = 1; m < 13; m++) { + if (m == 1 || m == 2) { + m += 12; + y--; + } + w = (1 + 1 + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7; + ww[a] = w; + a++; + if (m == 13 || m == 14) { + m -= 12; + y++; + } + }//ַɹ + for (int i = 1; i < 13; i++) { + t[i] = ww[i]; + } + for (aa = 1, bb = 2; aa <= 11, bb <= 12; aa += 2, bb += 2) { + tt = 6; + b = 1; + c = 1; + xingqi(aa); + while (tt--) { + if (tt == 5) { + for (int i = 0; i < ww[aa]; i++) { + printf(" "); + } + } + for (; b <= ri[aa]; b++) { + printf("%5d", b); + t[aa]++; + if (t[aa] == 7) { + t[aa] = 0; + cout << "\t\t"; + break; + } + } + b++; + if (t[aa] != 0) { + + for (; t[aa] < 7; t[aa]++) + cout << " "; + cout << "\t\t"; + } + if (tt == 0) + if (b > ri[aa]) { + cout << " \t\t\t\t"; + } + if (tt == 5) { + for (int i = 0; i < ww[bb]; i++) { + printf(" "); + } + } + if (y == 1582 && bb == 10) { + for (; c <= ri[bb]; c++) { + if (c == 5) { + c += 10; + } + printf("%5d", c); + t[bb]++; + if (t[bb] == 7) { + t[bb] = 0; + printf("\n"); + break; + } + } + if (c > ri[bb])cout << "\n"; + }////////////////////////// + else for (; c <= ri[bb]; c++) { + printf("%5d", c); + t[bb]++; + if (t[bb] == 7) { + t[bb] = 0; + printf("\n"); + break; + } + }//ѭִ\n + c++; + + if (tt == 0) { + cout << "\n"; + } + } + } + return; +} +int main(void) +{ + color(7); + string a; + int f=zhanshi(); + color(7); + if (f) + { + //system("cls"); + cout << "\nǷ볢ģ飿" << endl; + cout << "ǵĻYES" << endl; + cout << "볢ԵĻNO" << endl; + } + else + cout << "Bye Bye"<> a; + getchar(); + getline(cin, a); + system("cls"); + if (a == "YES") { + cout << "OK" << endl; + main(); + } + else if (a == "NO") { + cout << "ټ" << endl; + } + else { + cout << "ˣ" << endl; + return 0; + } + return 0; +} + + + + + + + + + + diff --git a/stu2024/数技2401赵仔航.c b/stu2024/数技2401赵仔航.c new file mode 100644 index 0000000..2bb20af --- /dev/null +++ b/stu2024/数技2401赵仔航.c @@ -0,0 +1,315 @@ +#include +#include +#include + + +int Leap (int year) //判断闰年 +{ + return (year%4==0&&year%100!=0)||(year%400==0); +} + +int Kimlareson(int year, int month, int day) +{ + if (month<3) //1,2月要当做去年的13,14月算 + { + month+=12; + year-=1; + } + + int K = year % 100; + int J = year / 100; + + + if (year<1582||(year==1582&&(month<10||(month==10&&day<=4))))//1582年10月4日及之前 + { + return (day+(13*(month+1))/5+K+K/4+5-J)%7; + } + + else //1582年10月15日及之后 + { + return (day+(13*(month+1))/5+K+K/4+J/4+5*J)%7; + } +} +int daysinmonth(int year,int month) +{ + switch(month) + { + case 2: + return Leap(year)?29:28; //判断2月天数 + case 4: case 6: case 9: case 11: + return 30; + default: + return 31; + } +} +void print_month_calendar(int year,int month,int *start_day)//单个月的日历 +{ + const char *months[]={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"}; + printf("\n %d %s\n",year,months[month - 1]); + printf("日 一 二 三 四 五 六\n"); + int days_in_month=daysinmonth(year,month); + + for (int i=0;i<*start_day;i++) + { + printf(" "); + } + + for (int day=1;day<=days_in_month;day++) + { + + printf("%2d ",day); + if ((*start_day+day)%7==0) + { + printf("\n"); + } + } + printf("\n"); + + *start_day=(*start_day+days_in_month)%7; +} +void print_1582(int *start_day) //单独处理1582年10月这个怪胎(?) +{ + printf("\n 十月 1582\n"); + printf("日 一 二 三 四 五 六\n"); + + + for (int i=0;i<*start_day;i++) + { + printf(" "); + } + + // 打印1-4日 + for (int day=1;day<=4;day++) + { + printf("%2d ",day); + if ((*start_day+day-1)%7==6) + { + printf("\n"); + } + } + + + int current_day=5; //跳过5-14日 + for (int day=15;day<=31;day++) + { + if ((*start_day+current_day-1)%7==0) + { + printf("\n"); + } + printf("%2d ",day); + current_day++; + } + printf("\n"); + + + *start_day=(*start_day+21)%7; //1582年10月只有21天 +} +void print_calendar(int year) //打印单列日历 +{ + int start_day=Kimlareson(year,1,1); + for (int month=1;month<=12;month++) + { + if (year==1582&&month==10) + { + print_1582(&start_day); //处理1582年10月 + } + else + { + print_month_calendar(year,month,&start_day); + } + } +} + +void print_calendar_double(int year) //打印双列整年日历 +{ + int start_day[12]; + start_day[0]=Kimlareson(year,1,1); + + + for (int month=1;month<12;month++) //计算每月起始星期几 + { + start_day[month]=(start_day[month-1]+daysinmonth(year,month))%7; + } + + const char *months[]={"一月", "二月", "三月", "四月", "五月", "六月","七月", "八月", "九月", "十月", "十一月", "十二月"}; + + for (int i = 0; i < 6; i++) //每行输出两个月 + { + printf("\n"); + + for (int j = 0; j < 2; j++) //两个月的标题 + { + int month = i * 2 + j + 1; + printf(" %d %s ",year,months[month-1]); + } + printf("\n"); + + + for (int j = 0; j < 2; j++) //星期标题 + { + printf("日 一 二 三 四 五 六 "); + } + printf("\n"); + + int max_days[2] = { daysinmonth(year, i * 2 + 1), daysinmonth(year, i * 2 + 2) };//获取两个月的最大天数和起始星期几 + int start_days[2] = { start_day[i * 2], start_day[i * 2 + 1] }; + + //打印日期 + int day[2] = {1, 1}; //每个月的当前日期 + int printed_anything = 1; //标记是否有剩余日期可打印 + + while (printed_anything) { + printed_anything = 0; + + for (int j = 0; j < 2; j++) + { + + if (day[j] == 1) //打印月初的空格 + { + for (int k = 0; k < start_days[j]; k++) + { + printf(" "); + } + } + + + while (day[j] <= max_days[j] && ((day[j] + start_days[j] - 1) % 7) != 6)//打印日期 + { + printf("%2d ",day[j]++); + printed_anything=1; + } + + + if (day[j] <= max_days[j])//打印最后一个日期,换行并跳到下一个月 + { + printf("%2d ",day[j]++); + printed_anything=1; + } else + { + printf(" "); //填充空格保持对齐 + } + + printf(" "); //每月之间的间隔 + } + + printf("\n"); //换行到下一个星期 + } + } +} + + +int main() +{ + SetConsoleOutputCP(65001); + int x; + for(;x!=4;) + { + printf(" menu\n"); + printf("[1]判断是否闰年\n"); + printf("[2]输出该年份的日历\n"); + printf("[3]求这一天是星期几\n"); + printf("[4]退出\n"); + + + scanf("%d",&x); + + if(x==1) + { + int y,x; + printf("请输入年份:"); + scanf("%d",&y); + if (y<0) + { + printf("你确定你输的是对吗?\n"); + } + else if(y>=10000) + { + printf("%d...你不觉得太过久远了吗?\n",y); + } + else + { + x=Leap(y); + if(x==1) + printf("是闰年\n"); + else + printf("不是闰年\n"); + } + } + else if(x==2) + { + int y,x; + printf("请输入年份:"); + scanf("%d",&y); + if (y<0) + { + printf("你确定你输的是对吗?\n"); + } + else if(y>=10000) + { + printf("%d...你不觉得太过久远了吗?\n",y); + } + else + { + printf("请选择单列或双列输出(1.单列 2.双列):"); + scanf("%d",&x); + if(x==1) + { + print_calendar(y); + } + else if(x==2) + { + print_calendar_double(y); + } + else + { + printf("啧...我觉得我说的很明显了呢...\n"); + } + } + } + else if(x==3) + { + int year, month, day; + printf("请输入日期(年 月 日):"); + scanf("%d %d %d", &year, &month, &day); + if(year<0||month<=0||day<=0) + { + printf("你是认真的吗?\n"); + } + else if(year>=10000) + { + printf("%d...你不觉得太过久远了吗?\n",year); + } + else if(month>=13||day<=0||day>31) + { + printf("你是认真的吗?\n"); + } + else if((month==2&&Leap(year)&&day>29)||(month==2&&Leap(year)==0&&day>28)) + { + printf("你是认真的吗?\n"); + } + else if(year==1582&&month==10&&day>4&&day<15) + { + printf("这一天已经被教皇大人吃掉了www\n"); + } + else + { + int weekday=Kimlareson(year, month, day); + const char *weekdays[] = {"星期六","星期日","星期一","星期二","星期三","星期四","星期五"}; + + printf("%d年%d月%d日是:%s\n",year,month,day,weekdays[weekday]); + } + } + else if(x==4) + exit(0); + else if(x==99) + printf("你先生,何时来的?\n是要时停扫地偷胖次吗?\n"); + else + { + printf("请不要开玩笑了,我没有这个功能哦\n"); + } + } + + + + return 0; +} \ No newline at end of file diff --git a/stu2024/数技2402季界通.cpp b/stu2024/数技2402季界通.cpp new file mode 100644 index 0000000..09310d7 --- /dev/null +++ b/stu2024/数技2402季界通.cpp @@ -0,0 +1,359 @@ +#include +#include +/*꺯*/ +int isLeapYear(int year) +{ + if (year == 1582) + { + return 0; + } + return ((year % 4 == 0 && year % 100!= 0) || (year % 400 == 0)); +} +int getFirstDayOfYear(int year) +{ + int d = (year - 1) * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400; + if (year > 1582) + { + if (year == 1583) + { + d -= 10; + } + } + return d % 7; +} +/*ڼĺ*/ +int getDayOfWeek(int year, int month, int day) +{ + int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; + if (month < 3) + { + year--; + } + return (year + year / 4 - year / 100 + year / 400 + t[month - 1] + day) % 7; +} + +/**/ +int danlie(int year) +{ + int c[12]={31,28,31,30,31,30,31,31,30,31,30,31}; + + if((year%4==0&&year%100!=0)||year%400==0) + c[1]++; + + int sum=(year-1)*365; + + if(year>1582) + sum-=10; + + for(int i=1;i1582) + sum-=10; + + for(int i=1;i4&&i<15) + continue; + printf("%5d",i); + if(i==16||i==23||i==30) + { + printf("\n"); + } + } + else + { + printf("%5d",i); + if(j%7==6) + printf("\n"); + } + } + if(mon==10) + { + d=(d+day+ 1)%7;//下个月第一天是周几 + printf("\n"); + } + d=(d+day)%7;//下个月第一天是周几 + printf("\n"); + } + } + } + else if(nums==2)//双列 + { + printf("输入年份"); + scanf("%d",&year); + a=(year%4==0&&year%100!=0||year%400==0); + b=((year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400+1)%7;//每年一月一日是周几 + for(mon=1;mon<=12;mon++) + { + switch(mon)//判每月天数 + { + case 1: + day=31; + break; + case 2: + if(a==1) + day=29; + else + day=28; + break; + case 3: + day=31; + break; + case 4: + day=30; + break; + case 5: + day=31; + break; + case 6: + day=30; + break; + case 7: + day=31; + break; + case 8: + day=31; + break; + case 9: + day=30; + break; + case 10: + day=31; + break; + case 11: + day=30; + break; + case 12: + day=31; + break; + } + printf("----------------%d月----------------|",mon++); + printf("----------------%d月----------------\n",mon); + printf(" 日 一 二 三 四 五 六"); + printf(" 日 一 二 三 四 五 六\n"); + switch(b)//判位置 + { + case 1: + printf("%5c",'\40'); + break; + case 2: + printf("%10c",'\40'); + break; + case 3: + printf("%15c",'\40'); + break; + case 4: + printf("%20c",'\40'); + break; + case 5: + printf("%25c",'\40'); + break; + case 6: + printf("%30c",'\40'); + break; + } + for(int i=1,j=b;i<=day;i++,j++) + { + printf("%5d",i); + if(j%7==6) + printf("\n"); + } + b=(b+day)%7;//下个月的第一天周几 + printf("\n"); + } + } + } + else if(num==2)//判星期 + { + int year,mon,day,a,b,c,d,e ; + printf("输入想要查询的具体日期\n"); + printf("年:\n"); + scanf("%d",&year); + printf("月:\n"); + scanf("%d",&mon); + printf("日:\n"); + scanf("%d",&day); + int arr[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + if(year==1582) + arr[10]=21; + a=(year%4==0&&year%100!=0||year%400==0); + b=((year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400+1)%7; + d=((year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400+11)%7; + if(year>1582) + { + if(a==1) + arr[2]=29; + for(int i=0;i10) + { + for(int i=0;i12) + { + printf("ÿΪ12·ݣ%dⷶΧ",b); + return 0; + } + if(b==1||b==3||b==5||b==7||b==8||b==10||b==12) + if(c<=0||c>31) + { + printf("Ϊ%d£¹31죬%dڴ˷Χ",b,c); + return 0; + } + if(b==4||b==6||b==9||b==11) + if(c<=0||c>30) + { + printf("Ϊ%d£¹30죬%dڴ˷Χ",b,c); + return 0; + } + if((a%4==0&&a%100!=0)||a%400==0) + if(b==2) + if(c<=0||c>29) + { + printf("Ϊ2£¹29죬%dڴ˷Χ",c); + return 0; + } + if(b==2) + if(c<=0||c>28) + { + printf("IJ2£¹28죬%dڴ˷Χ",c); + return 0; + } + if(a==1582&&b==10&&c>4&&c<15) + { + printf("Ϊԭ򣬲158210%d",c); + return 0; + } + + char weak[7][5]={"","","","","","һ","ܶ"}; + long long sum=365*(a-1)+c; + int p=a/100,m=a/400; + for(int l=1;l2) + sum++; + } + else + printf("%d겻\n",a); + if(a>1582) + sum-=10; + else if(a==1582&&b>10) + sum-=10; + else if(a==1582&&b==10&&c>=15) + sum-=10; + else + sum; + int k=sum%7; + printf("%d%d%dΪ%s",a,b,c,weak[k]); +} + +int danhang(int a) +{ + int c[12]={31,28,31,30,31,30,31,31,30,31,30,31}; + + if((a%4==0&&a%100!=0)||a%400==0) + c[1]++; + + int sum=(a-1)*365; + + if(a>1582) + sum-=10; + + for(int i=1;i1582) + sum-=10; + + for(int i=1;i +#include +#include + +int yearstartday(int Year); +bool isLeapYear(int Year); +int monthDays(int Year, int Month); +int getWeekDay(int Year, int Month, int Day); +void outMonthDays(int Year, int Month); +void outMonthDays1582(int Year, int Month); +void menu(); +void MenuChoice(int Choice); +void printYearCalendar(int Year); + +const char* weekDays[] = {"", "һ", "", "", "", "", ""}; + +int main() { + menu(); + return 0; +} + +int yearstartday(int Year) { + int detayear, corday, weekstartday, detaday; + detayear = Year - 2000; + if (detayear > 0) { + corday = 2; + detayear -= 1; + } else { + corday = 0; + if (detayear <= -418) { + corday = -3; + if (detayear <= -2000) { + corday = -1; + } + } + } + detaday = (detayear / 400) * 2 - detayear / 100 + detayear / 4 + detayear + corday; + weekstartday = (6 + detaday % 7) % 7; + return weekstartday; +} + +bool isLeapYear(int Year) { + return (Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0); +} + +int monthDays(int Year, int Month) { + if (Month == 1 || Month == 3 || Month == 5 || Month == 7 || Month == 8 || Month == 10 || Month == 12) { + return 31; + } else if (Month == 4 || Month == 6 || Month == 9 || Month == 11) { + return 30; + } else { + return isLeapYear(Year) ? 29 : 28; + } +} + +int getWeekDay(int Year, int Month, int Day) { + int i, temp, weekday, Days = 0; + for (i = 1; i <= Month - 1; i++) { + Days += monthDays(Year, i); + } + Days = Days + Day - 1; + temp = yearstartday(Year) + Days; + weekday = temp % 7; + if (Year == 1582 && Month > 10) { + weekday -= 3; + } + return weekday; +} + +void outMonthDays(int Year, int Month) { + int i, j, weekday; + printf(" %d\n", Month); + printf(" һ \n"); + weekday = getWeekDay(Year, Month, 1); + for (i = 0; i < weekday; i++) { + printf(" "); + } + for (j = 1; j <= monthDays(Year, Month); j++) { + printf("%4d", j); + if ((j + weekday) % 7 == 0) { + printf("\n"); + } + } + printf("\n"); + printf("-------------------------------------\n"); +} + +void outMonthDays1582(int Year, int Month) { + int i, j, weekday; + printf(" %d\n", Month); + printf(" һ \n"); + weekday = getWeekDay(Year, Month, 1); + for (i = 0; i < weekday; i++) { + printf(" "); + } + for (j = 1; j <= monthDays(Year, Month); j++) { + if (Month == 10) { + if (j > 4 && j < 15) { + } else { + printf("%4d", j); + if (j == 16 || j == 23 || j == 30) { + printf("\n"); + } + } + } else { + printf("%4d", j); + if ((j + weekday) % 7 == 0) { + printf("\n"); + } + } + } + printf("\n"); + printf("-------------------------------------\n"); +} + +void printYearCalendar(int Year) { + printf("Calendar for %d\n\n", Year); + for (int month = 1; month <= 12; month += 2) { + outMonthDays(Year, month); + printf("\n"); + if (month + 1 <= 12) { + outMonthDays(Year, month + 1); + printf("\n"); + } + } +} + +void menu() { + int choice; + while (1) { + printf("\n1. ڼ\n"); + printf("2. жƽ\n"); + printf("3. ij\n"); + printf("4. ˫ij\n"); + printf("5. ˳\n"); + printf("ѡ"); + scanf("%d", &choice); + MenuChoice(choice); + } +} + +void MenuChoice(int Choice) { + int Year, Month, Day; + switch (Choice) { + case 1: + printf(" գ"); + scanf("%d %d %d", &Year, &Month, &Day); + if (Year == 1582 && Month == 10 && Day > 4 && Day < 15) { + printf("15821051014ղ\n"); + } else { + int weekday = getWeekDay(Year, Month, Day); + printf("%d%d%d%s\n", Year, Month, Day, weekDays[weekday]); + } + break; + case 2: + printf("ݣ"); + scanf("%d", &Year); + if (isLeapYear(Year)) { + printf("%d\n", Year); + } else { + printf("%dƽ\n", Year); + } + break; + case 3: + printf("ݣ"); + scanf("%d", &Year); + if (Year == 0) { + printf("ûйԪ\n"); + } else { + if (Year > 0) { + printf(" Ԫ%dΪ:\n", Year); + } else { + printf(" Ԫǰ%dΪ:\n", -Year); + } + printf("=====================================\n"); + if (Year != 1582) { + for (Month = 1; Month <= 12; Month++) { + outMonthDays(Year, Month); + } + } else { + for (Month = 1; Month <= 12; Month++) { + outMonthDays1582(Year, Month); + } + } + } + break; + case 4: + printf("ݣ"); + scanf("%d", &Year); + if (Year == 0) { + printf("ûйԪ\n"); + } else { + printYearCalendar(Year); + } + break; + case 5: + printf("˳\n"); + exit(0); + default: + printf("Чѡ\n"); + } +} diff --git a/stu2024/数技2402樊璐瑶.cpp b/stu2024/数技2402樊璐瑶.cpp new file mode 100644 index 0000000..40fb99d --- /dev/null +++ b/stu2024/数技2402樊璐瑶.cpp @@ -0,0 +1,349 @@ +#include "stdio.h" +#include "stdlib.h" + +//判断闰年 +int isLeapYear(int year) +{ + if(year%400==0||(year%100!=0&&year%4==0)) + { + return 1; + } + return 0; +} + +// 计算某年某月的天数 +int daysInMonth(int year, int month) +{ + int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (month == 2 && isLeapYear(year)) + { + return 29; + } + return days[month - 1]; +} + +// 计算公元1年1月1日到给定日期的总天数 +int totalDays(int year, int month, int day) +{ + int total = 0; + for (int i = 1; i < year; i++) + { + if ((i % 4 == 0 && i % 100!= 0) || i % 400 == 0) + { + total += 366; + } else { + + total += 365; + } + } + for (int i = 1; i < month; i++) + { + if (year == 1582 && i == 10) + { + // 如果是1582年且计算到10月,减去10天 + if (day >= 15) + { + day -= 10; + } + } + total += daysInMonth(year, i); + } + total += day; + + return total; +} + +// 判断输入是否为合法的数字 +int isNumber(char *input) +{ + for (int i = 0; input[i]!= '\0'; i++) + { + if (input[i] < '0' || input[i] > '9') + { + return 0; + } + } + return 1; +} + +// 判断日期是否合法 +int isValidDate(int year, int month, int day) +{ + if (year <= 0) + { + return 0; + } + if (month < 1 || month > 12) + { + return 0; + } + if (day < 1 || day > daysInMonth(year, month)) + { + return 0; + } + return 1; +} + +//1852 +int a(int year,int month,int day) +{ + if(year==1582) + { + return 0; + } + if(month==10) + { + return 0; + } + if(day>4&&day<15) + { + return 0; + } + return 1; +} + +// 输出一个月的日历 +void printMonth(int year, int month) +{ + printf(" %d年%d月\n", year, month); + printf("日 一 二 三 四 五 六\n"); + int startDay = (totalDays(year, month, 1) % 7); + for (int i = 0; i < startDay; i++) + { + printf(" "); + } + int days = daysInMonth(year, month); + for (int i = 1; i <= days; i++) + { + printf("%2d ", i); + if ((totalDays(year, month, i) % 7) == 6) + { + printf("\n"); + } + } + if ((totalDays(year, month, days) % 7)!= 6) + { + printf("\n"); + } +} + +// 获取指定日期是周几 +int isWeek(int totalDay) { + return (totalDay % 7); +} + +// 计算某月某天的日期 +int Count_Day(int day[]) { + return (day[0] * 1000 + day[1] * 100 + day[2] * 10 + day[3]); +} + +// 双列输出日历的核心函数 +void printDoubleColumnCalendar(int year) { + // 对2个月分为6个块进行打印 + for (int block = 0; block < 6; ++block) { + // 打印表头 + printf("%2d月 %2d月 \n", block + 1, block + 7); + printf("日 一 二 三 四 五 六 日 一 二 三 四 五 六\n"); + + + int lineEnd_l = 1, lineEnd_r = 1; + int day_l[] = {year, block + 1, 1}; + int day_r[] = {year, block + 7, 1}; + int totalDay_l = Count_Day(day_l); + int totalDay_r = Count_Day(day_r); + + // 每个月有5行需要输出 + for (int line = 0; line < 5; ++line) { + // flag作标记位,每行有16个输出数字的位置,第9位和16位始终置0,其余位置不为0则输出数字 + int flag[16] = {0}; + // 标记第一行和其它行,用lineEnd_L和R作为整体的日期统计 + if (line == 0) { + int monthFirstday_l = isWeek(totalDay_l) + 1; + int monthFirstday_r = isWeek(totalDay_r) + 1; + for (int stringStation = monthFirstday_l; stringStation < 8; ++stringStation) { + flag[stringStation] = lineEnd_l++; + } + for (int stringStation = monthFirstday_l + 8; stringStation < 16; ++stringStation) { + flag[stringStation] = lineEnd_r++; + } + } else { + for (int stringStation = 1; stringStation < 8; ++stringStation) { + flag[stringStation] = lineEnd_l++; + if (lineEnd_l > (daysInMonth(year, block + 1))) { + break; + } + } + for (int stringStation = 9; stringStation < 16; ++stringStation) { + flag[stringStation] = lineEnd_r++; + if (lineEnd_r > (daysInMonth(year, block + 7) + 1)) { + break; + } + } + } + + // 输出每行的日期 + for (int i = 1; i < 16; ++i) { + if (i == 9) { + printf(" "); + } + if (flag[i] == 0) { + printf(" "); + } else { + if (flag[i] < 10) { + printf(" %d", flag[i]); + } else { + printf(" %d", flag[i]); + } + } + } + printf("\n"); + } + } +} +// 菜单选项1:判断闰年和星期几 +void option1(void) +{ + char yearStr[10], monthStr[10], dayStr[10]; + int year, month, day; + + // 输入年份并验证 + printf("请输入年份:"); + scanf("%s", yearStr); + if (!isNumber(yearStr)) + { + printf("输入错误,请输入数字!\n"); + return; + } + year = atoi(yearStr); + + // 输入月份并验证 + printf("请输入月份:"); + scanf("%s", monthStr); + if (!isNumber(monthStr)) + { + printf("请输入数字!\n"); + return; + } + month = atoi(monthStr); + + // 输入日期并验证 + printf("请输入日期:"); + scanf("%s", dayStr); + if (!isNumber(dayStr)) + { + printf("输入错误,请输入数字!\n"); + return; + } + day = atoi(dayStr); + + // 验证日期整体合法性 + if (!isValidDate(year, month, day)) + { + printf("日期不合法!\n"); + return; + } + + if(!a(year,month,day)) + { + printf("不存在此日期。\n"); + return; + } + + // 判断闰年并输出 + if (isLeapYear(year)) + { + printf("%d年是闰年。\n", year); + } + else + { + printf("%d年不是闰年。\n", year); + } + + // 计算并输出星期几 + int total = totalDays(year, month, day); + char *weekdays[] = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}; + printf("%d年%d月%d日是%s\n", year, month, day, weekdays[total % 7]); +} + +// 菜单选项2:输出一年的日历(实现较好的双列输出) +void option2(void) +{ + char choiceStr[10]; + int choice; + + // 选择输出方式并验证 + printf("请选择输出方式(1: 单列输出,2: 双列输出): "); + scanf("%s", choiceStr); + if (!isNumber(choiceStr)) + { + printf("输入错误,请输入数字!\n"); + return; + } + choice = atoi(choiceStr); + if (choice!= 1 && choice!= 2) + { + printf("选择错误!\n"); + return; + } + + char yearStr[10]; + int year; + + // 输入年份并验证 + printf("请输入年份:"); + scanf("%s", yearStr); + if (!isNumber(yearStr)) + { + printf("输入错误,请输入数字!\n"); + return; + } + year = atoi(yearStr); + if (year <= 0) + { + printf("年份不合法!\n"); + return; + } + + //单列输出 + if (choice == 1) + { + for (int month = 1; month <= 12; month++) + { + printMonth(year, month); + } + } + else + { + printDoubleColumnCalendar(year); + } + +} + +int main(void) +{ + int choice; + while(choice<=2) + { + // 显示菜单并获取用户选择 + printf("1. 判断闰年和星期几\n"); + printf("2. 输出一年的日历\n"); + printf("请选择:"); + scanf("%d", &choice); + + switch (choice) + { + case 1: + option1(); + break; + case 2: + option2(); + break; + default: + printf("退出程序\n"); + break; + } + + } + + return 0; +} \ No newline at end of file diff --git a/stu2024/数技2402赵思雨(1).cpp b/stu2024/数技2402赵思雨(1).cpp new file mode 100644 index 0000000..1bf8977 --- /dev/null +++ b/stu2024/数技2402赵思雨(1).cpp @@ -0,0 +1,460 @@ +#include +#include +#include +#include +void rili(int year,int pri){//1.· + int a,b,con=0; + int c=0; + int arr[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + a=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7;//жijһһ + if(year<=1582){ + a=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+11)%7; + } + if((year%4==0&&year%100!=0)||year%400==0) // + arr[2]=29; + if(pri==1){ // + for(int i=1;i<13;i++){ + printf("=======================%2d=======================\n",i); + printf("\tһ\t\t\t\t\t\n"); + if(year==1582&&i==11) + a=1; + if(year==1582&&i==112) + a=3; + if(a!=0){ + for(int x=1;x<=a;x++) + { + printf("\t"); + } + } + else + printf("\n"); + + + for(int j=1;j<=arr[i];j++) + { + if(year==1582&&i==10&&(j>4&&j<15)){ // + continue; + } + con+=1; + printf("%d\t",j); + if((con+a)%7==0||j==arr[i]) + printf("\n"); + } + a=(arr[i]+a)%7; + con=0; + printf("\n"); + + } + } //н + + else if(pri==2){ //˫ + con=0; + int q,m; + for(int i=1;i<13;i+=2){ + printf("=======================%2d=======================\t",i); + printf("=======================%2d=======================\n",i+1); + printf("\tһ\t\t\t\t\t\t\tһ\t\t\t\t\t\n"); + b=(arr[i]+a)%7; + q=7-b+1; + m=7-a+1; + if(year==1582&&i==11){ + a=1;b=3;m=7;q=5; + } + if(a!=0){ + for(int x=1;x<=a;x++) + { + printf("\t"); + } + } + + for(int x=1;x<=7-a;x++) + { + printf("%d\t",x); + } + if(year==1582&&i+1==10){ + printf("\t1\t2\t3\t4\t15\t16\t"); + q=17; + } + else{ + if(b!=0) + { + for(int x=1;x<=b;x++) + { + printf("\t"); + } + } + for(int y=1;y<=7-b;y++) + { + printf("%d\t",y); + } + } + + + + + printf("\n"); + /////////////////////////////////////һ + for(int j=m;j<=arr[i];j++) + { + + printf("%d\t",j); + + if(j==arr[i]&&(j+a)%7!=0){ + for(int g=0;g<=7-b-1;g++){ + printf("\t"); + } + } + + + if((j+a)%7==0||j==arr[i]){ + + for(int y=q;y<=arr[i+1];y++){ + printf("%d\t",y); + if(year==1582&&(i+1)==10){ + if(y==23||y==30||y==31){ + q=y+1; + printf("\n"); + break; + } + + else + continue; + + } + else{ + if(((y+b)%7==0||y==arr[i+1])&&j!=arr[i]){ + q=y+1; + printf("\n"); + break; + } + else if(j==arr[i]&&(y+b)%7==0&&y!=arr[i+1]){ + q=y+1; + printf("\n\t\t\t\t\t\t\t"); + continue; + } + } + + } + } + + if(year==1582&&i==9&&j==29) + printf("\n"); + + + } + a=(arr[i+1]+b)%7; + + printf("\n"); + + } + } + +} +void xingqi(int year,int mon,int day){ //ѯ + int a,b,con=0; + int arr[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + a=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7;//жijһһ + if(year<=1582){ + a=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+11)%7; + } + if((year%4==0&&year%100!=0)||year%400==0) // + arr[2]=29; + if(year==1582){ + arr[10]=21; + } + for(int i=1;i=15){ + b=(day-10)%7; + } + else + b=(a+day-1)%7; + switch(b){ + case 1:printf("һһ\n");break; + case 2:printf("һڶ\n");break; + case 3:printf("һ\n");break; + case 4:printf("һ\n");break; + case 5:printf("һ\n");break; + case 6:printf("һ\n");break; + case 0:printf("һ\n");break; + } +} +void run(int year){ //ж + if((year%4==0&&year%100!=0)||year%400==0) + printf("%d\n",year); + else + printf("%d\n",year); +} +bool nian(int year){ + if(year>0&&year<10000) + return true; + else + return false; +} +bool yue(int mon){ + if(mon>0&&mon<13) + return true; + else + return false; +} +bool ri(int year,int mon,int day){ + int arr[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + if((year%4==0&&year%100!=0)||year%400==0) // + arr[2]=29; + if(year==1582&&mon==10&&day>4&&day<15) + return false; + if(day>0&&day<=arr[mon]) + return true; + + else + return false; +} +///////////////////////////////////////////////////////////////////////////////////////////////////////////// +int main(){ +qwe:printf("1.ѯӦݵ\n2.ѯӦڵ\n3.ѯӦǷΪ\n4.˳\n(Ҫ밴0)\n"); + printf("ѡҪִеĿ\n"); + char num[100001]; //ѡĿ + int year=0,pri=0,mon=0,day=0,a,b,c;// ʽ + char y[100001],p[100001],m[100001],d[100001]; + while(gets(num)){ + year=0;pri=0;mon=0;day=0; + if(strlen(num)!=1){ + printf("룺\n"); + continue; + } + if(num[0]=='1'){ +asd: printf("Ҫѯݣ\n"); + edc: while(gets(y)){ + year=0; + if(y[0]=='0'&&strlen(y)==1){ + goto qwe; + } + if(strlen(y)<=4){ + for(int i=0;i='0'&&y[i]<='9'){ + continue; + } + else + { + printf("룺\n"); + goto edc; + } + } + break; + } + else{ + printf("룺\n"); + continue; + } + + } + a=strlen(y)-1; + c=strlen(y); + while(a>=0){ + + b=((int)y[a]-48)*pow(10,c-a-1); + year+=b; + a-=1; + } + while(!nian(year)){ + printf("룺\n"); + goto edc; + } + printf("ѡıʽ\n1.\n2.˫\n"); +bnm: while(gets(p)){ + + if(p[0]=='0'&&strlen(p)==1){ + goto asd; + } + if(strlen(p)>1||(strlen(p)==1&&(p[0]>'2'||p[0]<'1'))){ + printf("룺\n"); + continue; + } + else + break; + } + pri=(int)p[0]-48; + while(pri!=1&&pri!=2){ + printf("12\n"); + goto bnm; + } + + rili(year,pri); + //ִ1 + } + else if(num[0]=='2'){ +rty: printf("Ҫѯľ\n"); + printf("꣺"); +wsx: while(gets(y)){ + year=0; + if(y[0]=='0'&&strlen(y)==1){ + goto qwe; + } + if(strlen(y)<=4){ + for(int i=0;i='0'&&y[i]<='9'){ + continue; + } + else + { + printf("룺\n"); + goto wsx; + } + } + break; + } + else{ + printf("룺\n"); + continue; + } + + } + a=strlen(y)-1; + c=strlen(y); + while(a>=0){ + + b=((int)y[a]-48)*pow(10,c-a-1); + year+=b; + a-=1; + } + while(!nian(year)){ + printf("룺\n"); + goto wsx; + } + +uio: printf("£"); +qaz: while(gets(m)){ + mon=0; + if(m[0]=='0'&&strlen(m)==1){ + goto rty; + } + if(strlen(m)>2||(strlen(m)<=2&&((m[0]>'9'||m[0]<'0')||((m[1]>'9'||m[1]<'0')&&m[1]!='\0')))){ + printf("룺\n"); + continue; + } + else + break; + } + a=strlen(m)-1; + c=strlen(m); + while(a>=0){ + + b=((int)m[a]-48)*pow(10,c-a-1); + mon+=b; + a-=1; + + } + + if(!yue(mon)){ + printf("·룺\n"); + goto qaz; + } + printf("գ"); + rfv: while(gets(d)){ + day=0; + if(d[0]=='0'&&strlen(d)==1){ + goto uio; + } + if(strlen(d)>2||(strlen(d)<=2&&((d[0]>'9'||d[0]<'0')||((d[1]>'9'||d[1]<'0')&&d[1]!='\0')))){ + printf("룺\n"); + continue; + } + else + break; + } + a=strlen(d)-1; + c=strlen(d); + while(a>=0){ + + b=((int)d[a]-48)*pow(10,c-a-1); + day+=b; + a-=1; + } + while(!ri(year,mon,day)){ + printf("룺\n"); + goto rfv; + } + xingqi(year,mon,day); + } + else if(num[0]=='3'){ //3 + printf("Ҫѯݣ\n"); +tgb: while(gets(y)){ + year=0; + if(y[0]=='0'&&strlen(y)==1){ + goto qwe; + } + if(strlen(y)<=4){ + for(int i=0;i='0'&&y[i]<='9'){ + continue; + } + else + { + printf("룺\n"); + goto tgb; + } + } + break; + } + else{ + printf("룺\n"); + continue; + } + + } //пַ + a=strlen(y)-1; + c=strlen(y); + while(a>=0){ + + b=((int)y[a]-48)*pow(10,c-a-1); + year+=b; + a-=1; + } + while(!nian(year)){ + printf("룺\n"); + goto tgb; + } //д + + + + run(year); + } + else if(num[0]=='4')break; + + else{ //д + printf("룺\n"); + continue; + } + printf("Ҫʹһ˼޵\n1.õ\n2.\n");// + char ok[100001]; + + int f=ok[100001]-48; + +okf: while(gets(ok)){ + + if(strlen(ok)>1||(strlen(ok)==1&&(ok[0]>'2'||ok[0]<'1'))){ + printf("룺\n"); + continue; + } + else + break; + } + f=(int)ok[0]-48; + while(f!=1&&f!=2){ + printf("12\n"); + goto okf; + } + if(f==2)break; + else if(f==1){ + system("cls"); + goto qwe; + } + + + + } + + +} diff --git a/stu2024/数科2401易诗雅.c b/stu2024/数科2401易诗雅.c new file mode 100644 index 0000000..b31d148 --- /dev/null +++ b/stu2024/数科2401易诗雅.c @@ -0,0 +1,236 @@ +#include + +int isLeapYear(int year) +{ + return (year % 4 == 0 && year % 100!= 0) || (year % 400 == 0); +} + +int getDaysInMonth(int year, int month) +{ + int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (month == 1 && isLeapYear(year)) + { + return 29; + } + return daysInMonth[month]; +} + +void printCalendarHeader() +{ + printf(" Sun Mon Tue Wed Thu Fri Sat\n"); +} + +void printMonth(int year, int month) +{ + int z; + int days = getDaysInMonth(year, month); + int firstDayOfMonth = (year * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; + int i,day; + for (i = 0; i < month; i++) + { + firstDayOfMonth += getDaysInMonth(year, i); + } + firstDayOfMonth %= 7; + printCalendarHeader(); + for (i = 0; i < firstDayOfMonth; i++) + { + printf(" "); + } + for (day = 1; day <= days; day++) + { + printf("%5d", day); + if ((firstDayOfMonth + day) % 7 == 0) + { + printf("\n"); + } + } +} + +int main(void) +{ + int choice; + printf("1. ѯӦ\n"); + printf("2. ѯӦ\n"); + printf("3. жǷΪ\n"); + printf("4. ˳\n"); + scanf("%d", &choice); + int year,month,week,day,day_x,day_z=0,c=0; + int i,j,k,l,m,n,b; + char a; + start: + switch (choice) + { + case 1: + printf("ݣ"); + scanf("%d", &year); + int month; + int z; + printf("1.\n2.˫\n"); + scanf("%d",&z); + for (month = 0; month < 12; month++) + { + printf("\n %d\n", month + 1); + printMonth(year, month); + } + break; + case 2: + printf("òѯݣ\n"); + scanf("%d",&year); + printf("òѯ·ݣ\n"); + scanf("%d",&month); + printf("òѯ: \n"); + scanf("%d",&day); + if(year<1 || year>9999) + { + printf("ݴ:"); + scanf("%d",&year); + } + if(month<1 || month>12) + { + printf("·ݴ:"); + scanf("%d",&month); + } + if(day<1 || day>31) + { + printf("ڴ룺"); + scanf("%d",&day); + } + if(month<3) + { + year--; + month+=12; + } + if(year==1582 && month==10) + { + day_x=21; + if(day>=15) + { + k=year%100;j=year/100;l=day;m=month; + n=(l+(26*(m+1)/10)+k+(k/4)+(j/4)+5*j)%7; + switch(n) + { + case 0: + printf(""); + break; + case 1: + printf(""); + break; + case 2: + printf("һ"); + break; + case 3: + printf("ڶ"); + break; + case 4: + printf(""); + break; + case 5: + printf(""); + break; + case 6: + printf(""); + break; + } + break; + } + else + { + l=day+10; + k=year%100;j=year/100;m=month; + n=(l+(26*(m+1)/10)+k+(k/4)+(j/4)+5*j)%7; + switch(n) + { + case 0: + printf(""); + break; + case 1: + printf(""); + break; + case 2: + printf("һ"); + break; + case 3: + printf("ڶ"); + break; + case 4: + printf(""); + break; + case 5: + printf(""); + break; + case 6: + printf(""); + break; + } + } + break; + } + else + { + k=year%100;j=year/100;l=day;m=month; + n=(l+(26*(m+1)/10)+k+(k/4)+(j/4)+5*j)%7; + switch(n) + { + case 0: + printf(""); + break; + case 1: + printf(""); + break; + case 2: + printf("һ"); + break; + case 3: + printf("ڶ"); + break; + case 4: + printf(""); + break; + case 5: + printf(""); + break; + case 6: + printf(""); + break; + } + } + break; + case 3: + printf("ݣ\n"); + scanf("%d",&year); + if(year%4==0 && year%100!=0 || year%400==0) + { + printf("%d\n",year); + } + else + { + printf("%d\n",year); + } + break; + case 4: + a=choice; + if(a==4) + { + return 0; + } + break; + default: + printf("Чѡ(1~4):\n"); + scanf("%d",&choice); + do + { + if(choice>4 || choice==0) + { + printf("Чѡ:"); + continue; + } + else + { + break; + } + } + while(choice<=4 && choice!=0); + goto start; + } + return 0; +} diff --git a/stu2024/数科2401谢诗涵.c b/stu2024/数科2401谢诗涵.c new file mode 100644 index 0000000..f0d12c3 --- /dev/null +++ b/stu2024/数科2401谢诗涵.c @@ -0,0 +1,150 @@ +#include + +int main() { + int choice; + int j,k,l,m,n; + printf("˵ѡ\n"); + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ\n"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n"); + printf("ѡ(1-4)"); + scanf("%d", &choice); + start: + switch (choice) { + case 1: + + printf("Ҫѯ\n"); + + int year; + scanf("%d", &year); + int month,day; + int i,k; + + + // + printf("£\n"); + for (month = 1; month <= 12; month++) { + // ÿµ飬ȰãǷ2 + int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if ((year % 4 == 0 && year % 100!= 0) || year % 400 == 0) { + daysInMonth[1] = 29; + } + + // 1ڼϹʽ򻯰˼· + int y = year % 100; + int c = year / 100; + if (month < 3) { + y -= 1; + c -= 1; + } + int firstDay = (1 + (13 * (month + 1) / 5) + y + (y / 4) + (c / 4) - 2 * c) % 7; + firstDay = firstDay < 0? firstDay + 7 : firstDay; + + // ·ݱ + printf(" %d%d\n", year, month); + printf(" һ \n"); + + // 1ǰĿո + for (i = 0; i < firstDay; i++) { + printf(" "); + } + + // ÿ + int numDays = daysInMonth[month - 1]; + for (day = 1; day <= numDays; day++) { + printf("%2d ", day); + if ((firstDay + day) % 7 == 0) { + printf("\n"); + } + } + + // һв7任 + if ((firstDay + numDays) % 7!= 0) { + printf("\n"); + } + + printf("\n"); + } + + + + + break; + + case 2: + + printf("Ҫѯ\n"); + { + + printf("òѯݣ\n"); + scanf("%d",&year); + printf("òѯ·ݣ\n"); + scanf("%d",&month); + printf("òѯ: \n"); + scanf("%d",&day); + if(month<3) + { + year--; + month+=12; + } + k=year%100;j=year/100;l=day;m=month; + n=(l+(26*(m+1)/10)+k+(k/4)+(j/4)+5*j)%7; + switch(n) + { + case 0: + printf(""); + break; + case 1: + printf(""); + break; + case 2: + printf("һ"); + break; + case 3: + printf("ڶ"); + break; + case 4: + printf(""); + break; + case 5: + printf(""); + break; + case 6: + printf(""); + break; + } + break; + } + + case 3: + printf("Ҫѯ\n"); + { + + int year; + printf("һݣ"); + scanf("%d", &year); + if ((year % 4 == 0 && year % 100!= 0) || year % 400 == 0) { + printf("%d\n", year); + } else { + printf("%d겻\n", year); + } + +} + break; + case 4: + printf("˳...\n"); + break; + default: + + printf("Чѡ(1~4)\n"); + scanf("%d",&choice); + if(choice<=4) + { + goto start; + } + } + + + return 0; +} diff --git a/stu2024/网络2401郑世凯_02.cpp b/stu2024/网络2401郑世凯_02.cpp new file mode 100644 index 0000000..1848698 --- /dev/null +++ b/stu2024/网络2401郑世凯_02.cpp @@ -0,0 +1,150 @@ +// Created by Ricsae on 2024/11/13. +#include +using namespace std; +#define int long long +#define 初始化 system("CHCP 65001");system("cls");for(char i:str1)_str[0]+=i;for(char i:str2)_str[1]+=i; +#define Fexit system("pause");system("cls");break; +#define Fexit2 _sleep(300);printf_purple("请按下任意按键。");getchar();system("cls");break; + #define WTF cout <<" \n.i.:.....................:...:.:::::.:::::.....:.......:.:::...........:.::....:::.:::::::::::.............. . ....... .i:::::::::..:.....:\n"":7iii:i:i:i:::::::::i::iiiiiiiiiiiiiirrrrii:iiiii::.::iiiirii:i:i:iiiiiiririiiiiriiiiiriiiiirii::::::::::::.:.::::::i. i7ririririiii::::::i\n"".i.:.:.:...............:.:.:::::::::::::::::.:::.....:.:::::.....::::::i:i:i:i::::::::::::::::........................ :i::::::::::.......:\n"".i:.:.:...:.............:::::::::::::::::::.:::::.....::::i::::::::.. ....::i:::::::i:i::.:....................... :::::::::::::......:\n"".i.:.:.:.........:.:.:.:::::::::::::::::::::.::::....::::ii:.. .:::i::::::i:::...................:.. :i::::::::::::.....:\n"":::.:...:.........:.:.:::::::::::::::::::::.:.:::...:::.. . .:::...................: i::::::::::::...:..:\n"".i.:.:.:.....:.......:.:::::::::::::::::::::::::::.. :::::.................. .:i:::::::::::......:\n"".i:.:.:.:.:.:.........:::::::::::::::::::::::::.. .:::............... .i::::::::::::......:\n"".:.:.:.............:.:.::::::::::::::::::i:: .::::............ .ii:::::::::::......:\n"":::.:.:.:...:.......:.::::::::::::::::ri:. ..:::........ .i::::::::::::......:\n"".i.....:...:.:.....:.:.::::::::::::iiri. ...:..... :ii::::::::::...:...:\n"".:......:.:.:.........::::::::::::iii. ..:.. :i::::::::::::......:\n"".i.......:.:.........:.::::::::::ii. .:. :ii::::::::::::.....:\n"".:..:.:...:.....:...:.::::::::::ii. .. :i::::::::::::......:\n"".i...:.:.....:...:.:.::::::::::i: ..:i:::::::::::.......:\n""::..:.:::...:.:.:.:.:::::::::::: .ir:i::::::::::......:\n"".i...:::.:.:.:.:.:.:.:::::::::. :ii::::::::::.:.....:\n"".:..:.:.:.:.:.:.:.:.:::::::::. :ii::::::::::......:\n"".i...:.:.:.:.:.:.:.:.:::::::: .:i::::::::.......:\n"".:..:.:...:.:.:...:.:.::::::. .:i::::::::......:\n"".i.:.:.....:.:.:...:.::::::: .:i::::::.......:\n"".:....:.:.:::.:.:.:.:.:::::. :r: .:i::::::......:\n"".i...:.:.:::.:.:.:.:.::::::: rjUJ: .:.::i7r. .i::::.......:\n"".:......:.:.:.:...:.:.::::i. 7ZR2r. ..::iii:7vY7i. ::::::......:\n"".:.......:::.:.:.....::::::. iX27: ::iiriir7YYLYr: .::::.......:\n"".:..:....::.:.......:.::::: i: ..::ririrr7vsJj7r:. :::::......:\n"".:.:.....:::.:.:.....:::::. .u1 . :iiirrrrir77vvL7ri:. .::::......:\n"".:......:::.........::::::: LPU: ..:.::iiri7r7rrirrrrrii:::. .i.:.......\n"".:.......:::........:::::::. rsvYvYLvvYsY777v77ii::::::.. .:........:\n"".:......:::.:.......:::::.:. ivYssjYU2XSSSS2Ijvrrii:i::. :........:\n"".i.......:..........:::::::: .::rr .:rv7vLu152XSqIIuusYvv77ii. .:.......:\n"".:......:::...:.....:::::.:: .2BBBBBQui:. :ir7vvv7v7LvJuISKUjLL77rr :.:......:\n"".:.....:.:.........:::::.::: 7DBQBBRKuYvri:. ..ii777irir:.. . .:.......:\n"".:..................:::::.::. .ri .iv7i.....irv77::.... ...:......:\n"".:.................:::::.:::. rvYr .:...:iv5X5vi.....:........ ..........:\n"".:..............:..::.:::.::: 777rrr777riii:. .7i :iri7L5qESsi...:ir7Y5bgDg2Uj7:. ..........:\n"".:.............:...:::::... rrrrv7v1U1s7v777Lriirir5IsLvuUqPJr: .:irv2SdQBBBg2Uvr: ..:.......:\n"".:............:...:.:.:.:.:.i: :rrrvLjjIUUYYYv77r77vJSPKJ7r7LXSur: .i77: .:rii:. ..:........:\n"".:...........:.:...:.:.:.:rJM: irr7JS5dbbPKU2UIUS5PKPP27v777USuri. .rj7 ...........:\n"".:..................:.:..:vqX .rr7j25bPDEgZZbdbdEDbb2J77777jqXr:.....r7r7L7r.. .............\n"".:.................:.:::.:7q7 ir7v5IPqEEgEDZgEdEDDDqU77rrrY1qui.....:ivrrri:i:iii:. .:...........:\n"".:..................:.::..7Ur ir7sSPEggQQQQBQBBBRgIjrririv2bS7:.....:rvJ7vvvrrrririi:.. ::...........:\n"".:..................::::.:r2v ii7712PEgRQRBQQDbsriiiri7vsSgdIvi.....irvU1YjJI2SSbPKUsLvr:... :::...........:\n"".:..................:.:..:LjJ. .ir771USKdP5U2Liiiir7JvIPQBBBQSU7:....i7JX5U1uu21XXSXbPPIJ7r:::. ....:...........\n"".:.................:::::.:vJr. .iii7r7vYvYrrriirr77Lrr7gBBBBBPJvi:. i72PEqP255XKbPPPPS5UL7rii.. ................:\n"".:..................:::.::77i. .iiiirrrr7rrrrr7vYvr .:7Jvi:irri: :v2EPEPbKdPdPdbqI1YL7rii::. ..:...............\n"".:.....:.:.........:.:::.:i7i. :iiiirrrrrrrvv11uvvr. ii.. :7uIXqdKbqKPb5SU1Yv77ri::.. :::::...............:\n"".:..................:.:::.ivs: :rirrrr7r77j2S22Yv77r77Y7i :7ruUS2S5S25U2JY77rrii::.. :i::::::...............\n"".:...................:::..:77: :iiirr7r7L2u1uuJLvv7v7YsjjUsr.. .ir77uuuuUjjYv77rrri::.... .i::::.:...............:\n"".:..................:.:::.:::..:iiir7r77Lu1vsvsYJv7r77v7Yj2JY7v77r7r77v7vvJ7v7v77rrii::.... :::::::.:...............\n"".:...................:.:::::...::ii7r77v7vvYLv7vrriiirrrrvLJYsvYvLvJLYvLvvv777rrir::... ... .ii::::::...:...........:\n"".:..................:.:.:.:.:...::ii7r777i:. ..::rvJv7777L7YYL7vr7iiii::.. :YbI. ... :i::::::.:..............:\n"".:.................:.:.:...:....:::rr7rrii. .:. .iLYL77rvvv7vrrii::... :MBBBi .... :::::::::.:.............:\n""::..................:.:.:.:.:...::::rr7rrrr: .7dQbsui :7v7rrvv7rriri:... vBBBQr ...... .:::.:::::.:............:\n"".:.................:.:.:.:.:.....::::rirr7r7i:::. . ::rrv77rri:::. BBBB7 ....... :::.:.:.:...............:\n"".:................:.:.:::.:.:....:::iirrrrrrr::ivJI1J7i.. .. :irrrrii:... 7Yi ... ..... :i::.:.:.:..............:\n"".:.................:.:.:.:.:.....::::irrr7rrrr:::iir7s2qDMK2vr:.. ..::iii::::.. . . . .:.:. i::::.:.:.:.:...........:\n""..................:.:.:.:::.:.....:::irr7r777ii:. ..:rrrii:i::.... ... .::::. ..:.... .::.:::::.:.:.............\n"".:.............:...:.:.:.:.:::.......:i7r77v77ii:... .::iiiii::::.. ... ..... .i::.:::::...............:\n"".:................:::.:.:::.:.:.....::rrrrr7v7v77ri:i:i::::...::::i:i:i::. ........ .i:::::::.:...............\n"".:.................:.:.:.:::.:.... ..:irr7r77vjSS55X1Y77r7rrii:i:iiiii:. ......... .i::::.:.:...............:\n""..................:::.:.:.:.:.:::.. ..:i7r77vvu1X5qXKUs7v777rrririiiri. ........... .::.:.:.:.:...............\n"".. ................:.:::.:::.:::::.....:r7r77vvsJUu21svv7v77rrrriiii:. ............ .:.:.....:...............:\n""... ..............:.:.:.:.:.::::::::. .irrr7rvvL7LvL7vrrrrir:i::::.. ............. .:......:.................\n"".. ................:.:.:.:.:.::::i:... ..::iirrrrririi::::.:..... .............. .:.......................:\n""... ..............:.:::::.:.::i:: :::. ............... . .............. ..........................\n"".. . ..............:::::::::ii. :ii::.. ii:.................. ....................:\n""... . .............::.::ii:. iiii::.. .i::................ . ....................\n"".: ..............:.::::i:. 7Bi:iri::.. ::................ .... . ..................:\n""................::::::: YBS.:irir::... 7 .:.............. ..........................\n"".:.......:...:.::::. .QB :iiiririi::... .B. ............... ::.....:.................:\n"".:....::::::::::. BB irirrrrrii:i::.... :B2 ............ :::.......:..............:\n"":r:... :BB rrrirrriiirii::::.... . . . 7Bg .......... .::::.:...................:\n"" . DBB irrrrrrririr:i:::i:i::.. ... . . gQM .:...... .i::.:.:.:.:...............\n"" rBBB .irirrrrrrrii:::iiiiii: . ......... . 7QMQ .:... :::::::...:...............:\n"" gQBBQ irrrrrrirrrii:::i:iii. . ........... . rBQdB ... :r::::.....................\n"" .BEDBBr .rr7r7rrrririi:::iii:. . .................. rBBZDQ :iii::.:.................:\n"" rBEqBBB. .rrrr7rrrrrri:...:.. ...................... YBBDPZB :::::................:\n"" 7BKXqBBB .irrrrrrrrir::.. .............:....... QBBgPqgM ..:::.:::::.......:\n"" dBBBBBBBB7.ivsU22uJvLvv7r:i.:.::iiiiiiriiiriiiiii:i::LBQBBBBBBB ..:::..:"; +int y,m,d,cishu=0; +string _str[2]={"",""}; +string encodedStr = "|%E9%83%91%E4%B8%96%E5%87%AF"; +string decodedStr = "%E8%B0%81%E5%91%8A%E8%AF%89%E4%BD%A0%E8%BF%99%E4%B8%AA%E5%BD%A9%E8%9B%8B%E7%9A%84"; +string wk_zh[7]={"日","一","二","三","四","五","六"}; +string wk_en[7]={"Su","Mo","Tu","We","Th","Fr","Sa"}; +const int str1[]={56,56,50,50,52,54,52,54,66,65}; +const int str2[]={56,56,50,50,52,54,52,54,98,97}; +const int runPing[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31},}; + +int WeekDay(int y,int m,int d){ + if(y<1582||y==1582) {if(m<10||(m==10&&d<5))d+=3;else if(m==10&&(412)return false;if(d>runPing[IsLeapYear(y)][m])return false;return true;} +//颜色字 +string ToString(int n){string t=" ";char tm;if(n<10){tm=n+'0';t+=" ";t+=tm;return t;}else{tm=n/10+'0';t+=tm;tm=n%10+'0';t+=tm;return t;}} +string ToStringB(int n) {string result;while (n > 0) {result.push_back('0' + (n % 10));n /= 10;}reverse(result.begin(), result.end());return result;} +void print(const char* s) { printf("\033[0m\033[1;32m%s\033[0m", s); } +void printf_red(const char* s) { printf("\033[0m\033[1;31m%s\033[0m", s); } +void printf_blue(const char* s) { printf("\033[0m\033[1;34m%s\033[0m", s); } +void printf_purple(const char* s) { printf("\033[0m\033[1;35m%s\033[0m", s); } +void print_cd(int time,const char* s) {_sleep(time);printf_blue(s);} +void clearInput() {/*清除错误状态*/ + cin.clear();/*辅助函数,用于清理输入流*/ + cin.ignore(numeric_limits::max(), '\n'); /*忽略错误输入*/ + printf_red("非法输入,请重新输入!\n"); +} +void getdata(int n) {d=n%100,m=(n/100)%100,y=n/10000;} +void ToTrueDate() {/*int& y, int& m, int& d*/ + while(m>12)m-=12,y++; + while(d>runPing[IsLeapYear(y)][m]){d-=runPing[IsLeapYear(y)][m],m++;if(m>12)m=1,y++;} +} + +/*copy区:Unicode转码技术*/string urlDecode(const string& src) {string ret;for (size_t i = 0; i < src.length(); ++i) {if (src[i] == '%') {/*处理百分号编码*/if (i + 2 < src.length()) {std::string hex = src.substr(i + 1, 2);char decodedChar = static_cast(std::stoi(hex, nullptr, 16));/*将十六进制字符串转换为字符*/ret += decodedChar;i += 2; /*跳过已处理的部分*/}} else if (src[i] == '+') ret += ' ';/*'+' 号转换为一个空格*/else ret += src[i]; /*直接添加其他字符*/}return ret;} + +void PYear(int n){ + encodedStr+="|By:Ricsae"; + string decodedStr = urlDecode(encodedStr); + int day[12][6][7]={{{{0}}}}; + for(int k=0;k<12;++k){ + int FD=WeekDay(y,k+1,1); + int daynum=1; + for(int i=0;i<6;++i){ + for(int j=((daynum==1)?FD%7:0);j<7;++j){ + if(y==1582&&k==9&&daynum==5)daynum+=10; + if(daynum>runPing[IsLeapYear(y)][k+1])break; + day[k][i][j]=daynum++; + } + } + } + string str1="";for(int i=0;i<26*n+5;i++)str1+="=";str1+="|";int tempa=ToStringB(y).length();str1.replace(tempa+2, 1, "|");str1.replace(0, 2, "||");str1.replace(2, tempa, ToStringB(y));cout< 3) { clearInput(); continue;}// 应对非法输入的法二,弊端:过于麻烦,但可辅助输入 + if(choice=="1"){ + while(true) { + print("查周几 示例: 20190220为2月20日\n请输入日期:(如果我沉默了一定是你不对!!!)\n"); + getline(cin,temp);value=to_int(temp); + if(value<10000||cin.fail()){clearInput();continue;} + getdata(value); + if(d==0) continue; + if(!IsTureData()){printf_blue("很屑的了,搞点正常的不行吗?\n");ToTrueDate();cout<<"\033[0;34m猜你想知道"<>value;cin.ignore(1e9,'\n');//方案1 + getline(cin,temp);value=to_int(temp); + if(value<1||cin.fail()){clearInput();continue;} + if(IsLeapYear(value))cout<9999)printf("\033[0m\033[24;34m%s\033[0m", "这个年号害我笑一下\n"); + Fexit + } + }else if(choice=="3"){ + while(true) { + while(true){ + print("查日历 请输入年份:\n"); + getline(cin,temp);y=to_int(temp); + if(y<1||cin.fail()){clearInput();continue;} + break; + } + while(true){ + print("查日历 输出多少列:\n");int n=13; + getline(cin,temp);n=to_int(temp); + if(cin.fail()){clearInput();continue;} + if(01)print_cd(1000,"提示1:\n数字+字母\n"); + if(cishu>2)print_cd(1000,"提示2:\n数字是由其他方式代替来的\n"); + if(cishu>3)print_cd(1000,"真的没新提示了\n"); + if(cishu>4)print_cd(1000,"再有新提示的话会④人的\n"); + system("pause"); + system("cls"); + // 后后记:突然就明白了,什么叫防御式代码 + }else if(choice=="5"){ + break; }else if(choice==_str[0]||choice==_str[1]){cout< +using namespace std; + +// жǷΪ +bool run_nian(int year) { + return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; +} + +// ijijµ +int TIANSHU(int year, int month) { + static int days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + if (month == 2 && run_nian(year)) + return 29; + + return days[month]; +} + +// ָڼչʽ +int WEEK(int year, int month, int day) { + int week; + if (month < 3) { + month += 12; + year--; + } + int c = year / 100; + int y = year % 100; + if ((year < 1582) || (year == 1582 && month <= 10 && day <= 4)) + week = (day + 1 + 2 * month + 3 * (month + 1) / 5 + year + year / 4 + 5) % 7; + else if ((year > 1582) || (year == 1582 && month >= 10 && day >= 10)) + week = (c / 4 - 2 * c + y + y / 4 + 13 * (month + 1) / 5 + day - 1) % 7; + else + week = 8; + if (week < 0) + week += 7; + return week; +} + +// ӡ +void danlie(int year, int month) { + if (year != 1582) { + cout << " " << year << "" << month << "\n"; + cout << " һ \n"; + + int weekday = WEEK(year, month, 1); + for (int i = 0; i < weekday % 7; i++) + cout << " "; + + int days = TIANSHU(year, month); + for (int i = 1; i <= days; ++i) { + cout << setw(3) << i; + if ((weekday + i) % 7 == 0) + cout << "\n"; + } + cout << "\n"; + } else { + if (month != 10) { + cout << " " << year << "" << month << "\n"; + cout << " һ \n"; + + int weekday = WEEK(year, month, 1); + for (int i = 0; i < weekday % 7; i++) + cout << " "; + + int days = TIANSHU(year, month); + for (int i = 1; i <= days; ++i) { + cout << setw(3) << i; + if ((weekday + i) % 7 == 0) + cout << "\n"; + } + cout << "\n"; + } + + else { + cout << " " << year << "" << month << "\n"; + cout << " һ \n"; + + int weekday = WEEK(year, month, 1); + for (int i = 0; i < weekday % 7; i++) + cout << " "; + + int days = TIANSHU(year, month); + for (int i = 1; i <= days; ++i) { + if (i <= 4 || i > 14) + cout << setw(3) << i; + else + continue; + if (i == 16 || i == 23 || i == 30) + cout << "\n"; + } + cout << "\n"; + } + } +} + + + + + + +// ӡ˫ʾ£ +void shuang_yueli(int year, int month) { + int days1 = TIANSHU(year, month); + int days2 = TIANSHU(year, month + 1); + + cout << " " << year << "" << month << " - " << year << "" << month + 1 << "\n"; + cout << " һ һ \n"; + + int weekday1 = WEEK(year, month, 1); + int weekday2 = WEEK(year, month + 1, 1); + int i, j, ij1, ij2; + for (int m = 0; m < weekday1; ++m) + cout << " "; + for (i = 1; i < days1; i++) { + for (j = 1; j < days2; j++) { + for (ij1 = 1; ij1 <= (weekday1 + i) % 7; ij1++) { + cout << setw(3) << i; + i++; + } + for (int m = 0; m < weekday2; ++m) + cout << " "; + for (ij2 = 1; ij2 <= (weekday2 + j) % 7; ij2++) { + cout << setw(3)<< j; + j++; + if((weekday2+j)%7==0) + { + cout<<"\n"; + } + } + } + } +} + +// ʾ˵ȡûѡ +int menu() { + int choice; + cout << "˵\n"; + cout << "1. ѯijijijܼǷΪ\n"; + cout << "2. ָݵĵ\n"; + cout << "3. ָݵ˫\n"; + cout << "4. ˳\n"; + cout << "ѡ"; + while (scanf("%d", &choice) != 1) { + while (getchar() != '\n') ; + printf("Чѡ\n"); + } + return choice; +} + +// ȡЧ +int wannianli() { + int year; + cout << "ݣԪ󣩣"; + while (scanf("%d", &year) != 1) { + while (getchar() != '\n') ; + printf("Чѡ\n"); + } + return year; +} + +// ȡЧ· +int month_1() { + int month; + cout << "·ݣ1 - 12"; + while (scanf("%d", &month) != 1) { + while (getchar() != '\n') ; + printf("Чѡ\n"); + } + if (month > 12 || month < 1) { + printf("Чѡ\n"); + } + return month; +} + +// ȡЧ +int DAY(int year, int month) { + int date; + cout << "ڣ1 - " << TIANSHU(year, month) << ""; + while (scanf("%d", &date) != 1) { + while (getchar() != '\n') ; + printf("Чѡ\n"); + } + return date; +} + +int main() { + int choice; + do { + choice = menu(); + + switch (choice) { + case 1: { + int year = wannianli(); + int month = month_1(); + int date = DAY(year, month); + + bool leap = run_nian(year); + int weekday = WEEK(year, month, date); + if (weekday == 0) + cout << year << "" << month << "" << date << "졣\n"; + if (weekday == 8) + cout << year << "" << month << "" << date << "ղڡ\n"; + if (weekday < 8 && weekday > 0) + cout << year << "" << month << "" << date << "" << weekday << "\n"; + cout << year << (leap ? "ꡣ\n" : "ꡣ\n"); + break; + } + case 2: { + int year = wannianli(); + for (int month = 1; month <= 12; ++month) { + danlie(year, month); + } + break; + } + case 3: { + int year = wannianli(); + for (int month = 1; month < 12; month += 2) { + shuang_yueli(year, month); + } + break; + } + case 4: + cout << "˳\n"; + break; + default: + cout << "Чѡ롣\n"; + break; + } + } while (choice != 4); + + return 0; +} diff --git a/stu2024/网络2402崔依晨.cpp b/stu2024/网络2402崔依晨.cpp new file mode 100644 index 0000000..886dd6c --- /dev/null +++ b/stu2024/网络2402崔依晨.cpp @@ -0,0 +1,219 @@ +#include + +#include + +// жǷΪ +int runjudge(int year) { + if (year < 1582) { + // + return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); + } else { + // + return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); + } +} + +// ȡijµ +int getnumberdaysinmonth(int year, int month) { + if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) + return 31; + else if (month == 4 || month == 6 || month == 9 || month == 11) + return 30; + else if (month == 2) + return runjudge(year) ? 29 : 28; + else if (year == 1582 && month == 10) + return 21; // 1582104պΪ15գм10챻ɾԷ21 + else + return 0; // · +} + +// ijڼ +// ڣ繫Ԫ111գգ +int getstartday(int year, int month, int day) { + int sum = 0; + // Ŀǰһ + for (int y = 1; y < year; y++) { + sum += runjudge(y) ? 366 : 365; + } + // 1582꣬15821010 + if (year == 1582) { + for (int m = 1; m < 10; m++) { + sum += getnumberdaysinmonth(1582, m);//ú + } + sum += 4; // 158210ֻ㵽14 + } else { + // 㵽Ŀ·ǰһµ + for (int m = 1; m < month; m++) { + sum += getnumberdaysinmonth(year, m); + } + } + // Ŀµ + + + //ڼ + int wd = sum % 7; + + return (wd+7)%7; // +} + +// ӡڵıͷ +void printbegin() { + printf(" Sun Mon Tue Wed Thu Fri Sat \n"); +} + +// ӡijµ +void printmonthday(int year, int month) { + int firstday = getstartday(year, month, 1); // ȡµһڼ + int monthday = getnumberdaysinmonth(year, month); // ȡ + + // ӡո + for (int i = 0; i < firstday; i++) { + printf(" "); // ÿոһڵĵԪ + } + + // ӡÿһ + for (int n = 1; n <= monthday; n++) { + printf("%4d", n); // + if ((firstday + n) % 7 == 0) { // ĩ + printf("\n"); + } + } + printf("\n"); // ĩ +} + +// ӡijµ +void printcalendar(int year, int month) { + printbegin(); + printmonthday(year, month); +} + +// ӡij·ݵ +void printyearcalendar(int year) { + for (int i = 1; i <= 12; ++i) { + printf("%d£\n", i); + printcalendar(year, i); + printf("\n"); + } +} + +void print_calendar(int firstday1, int monthday1, int firstday2, int monthday2,int m,int y) { + // ӡ + printf("%d %d£ %d %d£\n",y,m,y,m+1); + printf("Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat\n"); + // е + int max_rows = (monthday1 + firstday1 + 6) / 7; // 1µ,¼һ + if ((monthday2 + firstday2 + 6) / 7 > max_rows) { + max_rows = (monthday2 + firstday2 + 6) / 7; // 2µһΪڼ+һжȥ + } + for (int row = 0; row < max_rows; row++) { + // ӡ1 + for (int i = 0; i < 7; i++) {//ڲ㣬iΪÿһУzuobiaosuoyin + if (row * 7 + i < firstday1) { + printf(" "); // ӡո + } else if (row * 7 + i - firstday1 < monthday1) {// + printf("%-3d ", row * 7 + i - firstday1 + 1);//ֽڣǰλЧΧӡ + } else { + printf(" "); // ӡո + } + } + // ӡ + printf(" "); + // ӡ2 + for (int i = 0; i < 7; i++) { + if (row * 7 + i < firstday2) { + printf(" "); // ӡո + } else if (row * 7 + i - firstday2 < monthday2) { + printf("%-3d ", row * 7 + i - firstday2 + 1); + } else { + printf(" "); // ӡո + } + } + printf("\n"); // + } +} + +// ӡij·ݵ˫ +void printdoubleyearcalendar(int year,int month,int day) + { + printf("\n"); + for (int month = 1; month <= 12; month += 2) //ǶѭÿһУһڲѭ + { + + int firstday1= getstartday(year, month, 1); + + // ȡһµĵһ + int monthday1 = getnumberdaysinmonth(year, month); // ȡһµ + int firstday2 = getstartday(year, month + 1, 1); // ȡڶµĵһ + int monthday2 = getnumberdaysinmonth(year, month + 1); // ȡڶµ + print_calendar(firstday1, monthday1, firstday2, monthday2,month,year);// + } +} + + +int main(void) +{ + int choice,year,month,day; + int wwd=getstartday(year,month,day); + do{ + printf("\n======˵======\n"); + printf("1.һڣõܼ\n"); + printf("2.һݣõ\n"); + printf(" 2.1 \n"); + printf(" 2.2 ˫\n"); + + printf("3.һݣжǷΪ\n"); + printf("4.˳\n"); + printf("ѡһѡ"); + scanf("%d",&choice); + switch(choice) + { + case 1: + printf("Ҫҵ գ"); + scanf("%d %d %d",&year,&month,&day); + getstartday(year,month,day); + + printf("ҵΪ%d\n",wwd); + break; + case 2: + printf("ѡʽ\n"); + printf("1. \n"); + printf("2. ˫\n"); + + int outputChoice; + scanf("%d", &outputChoice); + printf("Ҫҵ: "); + scanf("%d", &year); + if (outputChoice == 1) { + printyearcalendar(year); // ӡ + } else if (outputChoice == 2) { + printdoubleyearcalendar(year,month,day); // ӡ˫ + } + else + { printf("Чʽ\n"); + } + break; + case 3: + printf("Ҫҵݣ"); + scanf("%d",&year); + runjudge(year); + if(runjudge(year)==1) + printf("һ\n"); + else + printf("ⲻһ\n"); + + break; + case 4: + printf("˳\n"); + break; + default: + printf("Чѡ\n"); + } + }while(choice!=4); + return 0; +} + + + + + + diff --git a/stu2024/网络2402朱治雨.c b/stu2024/网络2402朱治雨.c new file mode 100644 index 0000000..4a1c281 --- /dev/null +++ b/stu2024/网络2402朱治雨.c @@ -0,0 +1,51 @@ +#include + +int main(){ + int y,m,d,w,b,FOE=0; + char a[2]={'\0'}; + while(FOE==0){ + printf("˵:\n1 ָݵ\n2 ѯָڵ\n3 ѯָǷΪ\n4 ˳\n");//˵ + while(gets(a)){ + if(a[0]=='4'&&a[1]=='\0'){ FOE=1; break; }//˳; + else if(a[0]=='1'&&a[1]=='\0'){ + printf("Ҫѯݣ"); scanf("%d",&y); + printf("ıʽ\n1 \n2 ˫\n"); scanf("%d",&b); + if(b==1) printf("111"); + else if(b==2) printf("222"); + getchar(); + }//˫; + else if(a[0]=='2'&&a[1]=='\0'){ + printf("ѯľ\n꣺"); scanf("%d",&y); + printf("£"); scanf("%d",&m); + printf("գ"); scanf("%d",&d); + if(m==1||m==2) y--,m+=12; + if(y<=1582&&m<=10&&d<=4){ + if(m==1||m==2) y--,m+=12; + w=(d+2*m+3*(m+1)/5+y+y/4+5)%7+1; + } + else{ + if(m==1||m==2) y--,m+=12; + w=(d+1+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7; + } + if(w==0) w=7; + printf("%d.\nEnterԼ",w); + getchar(); + }//ڼ; + else if(a[0]=='3'&&a[1]=='\0'){ + printf("ѯݣ"); scanf("%d",&y); + if((y%4==0&&y%100!=0)||y%400==0) printf("%d .",y); + else printf("%d .EnterԼ\n",y); + getchar(); + }//ѯ; + + if(a[0]!='1'&&a[0]!='2'&&a[0]!='3'&&a[0]!='4'&&a[0]!='\0'){ printf("룺\n");a[0]='\0';a[1]='\0';continue;} + else if((a[0]=='1'||a[0]=='2'||a[0]=='3'||a[0]=='4')&&a[1]!='\0'){ printf("룺\n");a[0]='\0';a[1]='\0';continue;} + FOE=0; + if(a[0]!='\0') getchar(); + system("cls"); + a[0]='\0';a[1]='\0'; + break; + //(); + } + } +} diff --git a/stu2024/虚拟2401刘军保(1).c b/stu2024/虚拟2401刘军保(1).c new file mode 100644 index 0000000..352f64e --- /dev/null +++ b/stu2024/虚拟2401刘军保(1).c @@ -0,0 +1,192 @@ +#include +#include +//ж϶nֵ------------------------------------------------------------------------------------------------------- +int durun() { + int i; + char x; + printf("1.ѯijijڼǷΪ\n2.ӡ\n3.ӡ˫\n4.˳\n"); + scanf(" %c",&x); + if(x=='1') + x=1; + else if(x=='2') + x=2; + else if(x=='3') + x=3; + else if(x=='4') + x=4; + else x=5; + return x; +} +//ж------------------------------------------------------------------------------------------------------------- +int runian(int x1) { + int m=28; + if(x1%4==0&&x1%100!=0||x1%400==0) + m=29; + return m; +} +int riqi(int x1) { + int w,i; + if(x1>2000) + w=((x1-1)*365+((x1-1)/4)-((x1-1)/100)+((x1-1)/400)+1)%7; + else w=(x1/100)/4-2*(x1/100)+x1%100+(x1%100)/4+(13*12/5); + w=w%7; + if(w==0) + w=7; + return w; +} +//----------------------------------------------------------------------------------------------------------------- +int main() { + for(;;) { +qaz:; + int m[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31}; + int n,year,ri; + n=durun(); + if(n==5) { + system("cls"); + printf("\n\n"); + goto qaz; + } + if(n==4) + break; +//--------------------------------------------------------------------------------------------------------------------------- + if(n==1) { + system("cls"); +zaq:; + int xiqi,i; + printf(" \nһ-1\n"); + scanf("%d",&year); + if(year==-1) { + system("cls"); + goto qaz; + } + scanf("%d%d",&m[0],&ri); + m[2]=runian(year); + if(year<=9999&&year>0&&m[0]>=1&&m[0]<=12&&ri>0&&ri<=m[m[0]]) { + xiqi=riqi(year); + if(year==1582) { + if(m[0]==10&&ri>4&&ri<15) { + printf("\n\n"); + goto zaq; + } + if(m[0]>10) + m[10]-=10; + if(ri>=15&&m[0]==10) + xiqi=xiqi-10; + } + for(i=1; i0) { + printf("======================%.4d======================\n\n\n",year); + for(i=1; i<=12; i++) { + printf("=======================%.2d=======================\n",i); + printf("һ ڶ \n"); + for(j=1; j7) { + printf("\n"); + w=1; + } + } + printf("\n\n"); + } + } else printf("\n\n"); + } +//--------------------------------------------------------------------------------------------------------------------------------- + if(n==3) { + system("cls"); + int i,j1,w,w2,year; + int x1,x2,x3,x4,x5; + printf("\nһ-1\n"); + scanf("%d",&year); + if(year==-1) { + system("cls"); + goto qaz; + } + m[2]=runian(year); + w=riqi(year); + if(year<=9999&&year>0) { + printf("===============================================%.4d===============================================\n\n\n",year); + for(i=1; i<=12; i=i+2) { + x1=1,x3=1,x4=1; + printf(" \n"); + printf("=======================%.2d======================= ",i); + printf("=======================%.2d=======================\n",i+1); + printf("һ ڶ "); + printf(" һ ڶ \n"); + w2=(w+m[i])%7; + if(w2==0) + w2=7; + for(j1=1; j17) { + if(x1==1) { + for(x2=1; x27) { + x5=1; + printf("\n"); + break; + } + } + printf("\n"); + w=1; + } + } + if(year==1582&&i==9) + m[10]=21; + w=(w2+m[i+1])%7; + if(w==0) + w=7; + } + } else printf("\n\n"); + } + } +} diff --git a/stu2024/虚拟2401张博文.c b/stu2024/虚拟2401张博文.c new file mode 100644 index 0000000..cfda549 --- /dev/null +++ b/stu2024/虚拟2401张博文.c @@ -0,0 +1,123 @@ +#include +#include + +// жǷΪ +int isLeapYear(int year) { + return (year % 4 == 0 && year % 100!= 0) || (year % 400 == 0); +} +// ijж +int daysInMonth(int year, int month) { + int days[] = {31, 28 + isLeapYear(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + return days[month - 1]; +} + +// 190011յڵ +int totalDays(int year, int month, int day) { + int total = 0; + int y; + for (y = 1900; y < year; y++) { + total += 365 + isLeapYear(y); + } + int m; + for (m = 0; m < month; m++) { + total += daysInMonth(year, m); + } + total += day; + return total; +} + +// ӡ +void printCalendar(int year, int singleColumn) { + int startDay = (totalDays(year, 1, 1) + 1) % 7; + printf("Calendar - %d\n", year); + if (singleColumn) { + int month; + for ( month = 1; month <= 12; month++) { + int days = daysInMonth(year, month); + printf("\n\t%d\n", month); + printf("\tMon\tTue\tWed\tThu\tFri\tSat\tSun\n"); + int i; + for (i = 0; i < startDay; i++) + printf("\t"); + int day; + for (day = 1; day <= days; day++) { + printf("\t%d", day); + if ((startDay + day) % 7 == 0) + printf("\n"); + } + if ((startDay + days) % 7!= 0) + printf("\n"); + startDay = (startDay + days) % 7; + } + } else { + printf("\tMon\tTue\tWed\tThu\tFri\tSat\tSun\t\tMon\tTue\tWed\tThu\tFri\tSat\tSun\n"); + int month; + for (month = 1; month <= 12; month++) { + int days = daysInMonth(year, month); + int currentStartDay = (totalDays(year, month, 1) + 1) % 7; + int i; + for (i = 0; i < currentStartDay; i++) + printf("\t"); + int day; + for (day = 1; day <= days; day++) { + printf("\t%d", day); + if ((currentStartDay + day) % 7 == 0) + printf("\t\t"); + } + printf("\n"); + } + } +} + +// ѯijܼ +void queryDay() { + int year, month, day; + printf("( )"); + scanf("%d %d %d", &year, &month, &day); + int total = totalDays(year, month, day); + int weekDay = (total - 1) % 7; + char *weekDays[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat","Sun"}; + printf("%d%d%d %s\n", year, month, day, weekDays[weekDay]); + printf(" %s\n", isLeapYear(year)? "" : "ƽ"); +} + +// ˵ +void menu() { + int choice; + int year; + int singleColumn = 1; + while (1) { + printf("\n1. ѯijܼжǷΪ\n"); + printf("2. ӡijһ()\n"); + printf("3. ӡijһ(˫)\n"); + printf("4. ˳\n"); + printf("ѡ"); + scanf("%d", &choice); + switch (choice) { + case 1: + queryDay(); + break; + case 2: + printf("ݣ"); + scanf("%d", &year); + printCalendar(year, singleColumn); + break; + case 3: + singleColumn = 0; + printf("ݣ"); + scanf("%d", &year); + printCalendar(year, singleColumn); + singleColumn = 1; + break; + case 4: + exit(0); + default: + printf("Чѡѡ\n"); + } + } +} + +int main() { + menu(); + return 0; +} diff --git a/stu2024/虚拟2401彭子杰.c b/stu2024/虚拟2401彭子杰.c new file mode 100644 index 0000000..1224431 --- /dev/null +++ b/stu2024/虚拟2401彭子杰.c @@ -0,0 +1,164 @@ +#include + +int isAvailable(int year); +void getDay(int year,int first_day[]); +int weak(int year); +void drawCalendar(int days[],int first_day[]); + +int main(){ + int year=0; + int days[12]={31,28.31,30,31,30,31,30,31,30,31,30}; + int first_day[12]={0}; + int i,t; + + for(t=1;t==1;){ + int n; + printf("=============ȤʹȻ=============\n"); + printf("1.ѯij\n"); + printf("2,ѯijʲô\n"); + printf("3.ѯijijڼ\n"); + printf("4.˳ϵͳ\n\n"); + + + printf("ѡ:"); + scanf("%d",&n); + while(1){ + + if(n==1){ + printf("Ҫѯ:"); + scanf("%d",&year); + + if(!isAvailable(year)){ + break; + } + + getDay(year,first_day); + + if((year%4==0 && year%100!=0) || year%400==0){ + days[1]=29; + } + + drawCalendar(days,first_day); + putchar('\n'); + break; + } + + else if(n==2){ + printf("Ҫѯ:"); + scanf("%d",&year); + + if(!isAvailable(year)){ + break; + } + + if((year%4==0 && year%100!=0) || year%400==0){ + printf("%d\n",year); + } + else{ + printf("%dƽ\n",year); + } + putchar('\n'); + break; + } + else if(n==4){ + t=0; + break; + } + else{ + printf("Ҫѯ:"); + scanf("%d",&year); + if(!isAvailable(year)){ + break; + + } + int weak1=0; + weak1=weak(year); + printf("%d",weak1); + putchar('\n'); + break; + } + } + } + return 0; +} + +int isAvailable(int year){ + if(year>0){ + return 1; + } + return 0; +} +void getDay(int year,int first_day[]){ + int m=0; + int d=1; + int w=0; + int y=year; + for(m=3;m<=12;m++){ + w=(d + 1 + 2*m + 3*(m+1)/5 + y + y/4 - y/100 + y/400) % 7; + first_day[m]=w; + } + y-=1; + for(m=13;m<=14;m++){ + w=(d + 1 + 2*m + 3*(m+1)/5 + y + y/4 - y/100 + y/400) % 7; + first_day[m-13]=w; + } +} + +void drawCalendar(int days[],int first_day[]){ + int space=0; + int i=0,d=0,j=0; + for(i=0;i<12;i++){ + space=first_day[i]; + + printf(" %2d\n",i+1); + printf("|-----------------------------|\n"); + printf("| һ |\n"); + printf("|-----------------------------|\n|"); + + for(j=0;j +int main(){ + int n; + int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + for(;;){ + printf("1.ѯ\n2.ӡ\nҪ\n"); + scanf("%d",&n); + if(n==1) + { + int year,a=0,b,i,j; + printf(" · \n"); + scanf("%d",&year); + if(year%4==0&&year%100!=0||year%400==0) + m[2]=29; + scanf("%d",&m[0]); + scanf("%d",&b); + if(year==1582&&m[0]==10&&b>4&&b<15) + printf("\n"); + else if(year<0||m[0]<0||m[0]>12||b<0||b>31){ + printf("\n"); + }else if(m[2]==28&&b>28||m[2]==29&&b>29) + printf("\n"); + else if((m[0]==1||m[0]==3||m[0]==5||m[0]==7||m[0]==8||m[0]==10||m[0]==12)&&b==31) + printf("\n"); + else { + j=b; + if(year==1582){ + m[10]-=10; + if(b>=15) + b-=10; + } + if(year>=2000) + a=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7; + else a=(year/100)/4-2*(year/100)+year%100+(year%100)/4+(13*12/5); + for(i=1;i=15) + b-=10; + } + printf("%d%d%d%d\n",year,m[0],j,a); + if(m[2]==29) + printf("%d\n",year); + else printf("%d겻\n",year); + } + }else + if(n==2) + { + int year,a=0,i,j,b,f; + printf("\n"); + scanf("%d",&year); + if(year<0) + printf("\n"); + else { + printf("1.1*12\n2.2*6\nҪ\n"); + scanf("%d",&n); + if(year%4==0&&year%100!=0||year%400==0) + m[2]=29; + if(year>=2000) + a=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7; + else a=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7; + if(a==0) + a=7; + if(n==1) + { + printf("~~~~~~~~~~~~~~~~~~~~~~%.4d~~~~~~~~~~~~~~~~~~~~~~\n\n\n",year); + for(i=1;i<=12;i++){ + printf("~~~~~~~~~~~~~~~~~~~~~~~%.2d~~~~~~~~~~~~~~~~~~~~~~~\n",i); + printf("һ ڶ \n"); + for(b=1;b7){ + printf("\n"); + a=1; + } + }printf("\n"); + } + }else + if(n==2){ + int x1,x2,x3,x4; + printf("===============================================%.4d===============================================\n\n\n",year); + for(i=1;i<=12;i+=2){ + x2=1,x3=1; + printf("~~~~~~~~~~~~~~~~~~~~~~~%.2d~~~~~~~~~~~~~~~~~~~~~~~ ",i); + printf("~~~~~~~~~~~~~~~~~~~~~~~%.2d~~~~~~~~~~~~~~~~~~~~~~~\n",i+1); + printf("һ ڶ "); + printf("һ ڶ \n"); + for(b=1;bm[i+1]){ + break; + }else printf(" "); + a++; + if(a>7){ + if(x1==1){ + for(b=1;b7){ + printf("\n"); + + a=1; + x2++; + x4=1; + break; + } + } + } + } + if(year==1582&&(i+1)==10){ + m[10]-=10; + } + a=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7; + int x5; + for(x5=1;x5<=i+1;x5++) + a+=m[x5]; + a=a%7; + if(a==0) + a=7; + printf("\n"); + } + }else{ + printf("\n"); + return 0; + } + } + }else printf("\n"); + } +} diff --git a/stu2024/虚拟2401才忠鑫(1).cpp b/stu2024/虚拟2401才忠鑫(1).cpp new file mode 100644 index 0000000..8fe0ea9 --- /dev/null +++ b/stu2024/虚拟2401才忠鑫(1).cpp @@ -0,0 +1,259 @@ +#include +#include +#include + +// printʾ˵ʱӡǺźͿո +void print(char c, int n) +{ + int i; + for (i = 1; i <= n; i++) + { + putchar(c); + } +} + +// ѯijijijյܼ +int getWeekday(int year, int month, int day) { + // 1582104պڼĺ + if (year <= 1582) { + if (month < 3) { + year--; + month += 12; + } + int h = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400) % 7; + return h + 1; + } + // 1582104ռǰڼĺ + else if (year > 1582) { + if (month < 3) { + year--; + month += 12; + } + int c = year / 100; + int y = year % 100; + int m = month; + int d = day; + int w = c / 4 - 2 * c + y + y / 4 + (13 * (m + 1) / 5) + d - 1; + w = w % 7; + if (w < 0) { + w += 7; + } + return w; + } + return -1; +} + +// ںϷԵĺ +int isDateValid(int year, int month, int day) { + if (month < 1 || month > 12) { + return 0; + } + if (day < 1) { + return 0; + } + if (month == 2) { + if (((year % 4 == 0 && year % 100!= 0) || year % 400 == 0) && day > 29) { + return 0; + } + else if (day > 28) { + return 0; + } + } + return 1; +} + +// жǷΪ +int isLeapYear(int year) { + return ((year % 4 == 0 && year % 100!= 0) || year % 400 == 0); +} + +// ȡָ·ݵ +int getDaysInMonth(int month, int year) { + int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + if (month == 2 && isLeapYear(year)) { + return 29; + } + return days[month - 1]; +} + +// ͷ·ݺڣ +void printCalendarHeader(int month, int year) { + const char* months[] = { "һ", "", "", "", "", "", "", "", "", "ʮ", "ʮһ", "ʮ" }; + if (year == 1582 && month == 10) { + printf("\nʮ 1582 (Special Month)\n"); + } + else { + printf("\n%s %d\n", months[month - 1], year); + } + printf("һ ڶ \n"); +} + +// 壨ڲ֣ +void printCalendarBody(int month, int year, int format,int day) { + int daysInMonth = getDaysInMonth(month, year); + if (month < 3) { + year--; + month += 12; + } + int k = year % 100; + int j = year / 100; + int firstDay =(day + 13 * (month + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7-1; + if (format == 1) { // иʽ߼ + if (year == 1582 && month == 10) { + for (int day = 1; day <=4; day++) { + printf(" %.2d ", day); + if ((firstDay + day) % 7 == 0) { + printf("\n"); + } + } + for (int day = 15; day <= daysInMonth; day++) { + printf(" %.2d ", day); + if ((firstDay + day) % 7 == 0) { + printf("\n"); + } + } + }else { + for (int i = 0; i < firstDay; i++) { + printf(" "); + } + for (int day = 1; day <= daysInMonth; day++) { + printf(" %.2d ",day); + if((firstDay + day) % 7 == 0){ + printf("\n"); + } + } + } + }else { //˫иʽ߼ + if (year == 1582 && month == 10) { + for (int day = 1; day <=4; day++) { + printf(" %.2d ", day); + } + for (int day = 15; day <= daysInMonth; day++) { + printf(" %.2d ", day); + if ((firstDay + day) % 7 == 0) { + printf("\n"); + } + } + if ((firstDay + daysInMonth) % 7!= 0) { + printf("\n"); + } + } + else { + for (int i = 1; i < firstDay; i++) { + printf(" "); + } + + for (int day = 1; day <= daysInMonth; day++) { + printf(" %.2d ", day); + if ((firstDay + day) % 7 == 6) { + printf("\n"); + } + } + if ((firstDay + daysInMonth) % 7!= 6) { + printf("\n"); + } + } + } +} +void showMenu() +{ + putchar('\n'); + print(' ', 10); + print('*', 60); + putchar('\n'); + print(' ', 20); + printf("1--ѯijijijյܼ\n"); + print(' ', 20); + printf("2--ǷΪ\n"); + print(' ', 20); + printf("3--ݣһ\n"); + print(' ', 10); + print('*', 60); + putchar('\n'); +} + +int main() +{ + int choice; + char ifcontinue; + int year, month, day; + + showMenu(); + // ѡ˵ + while (1) { + printf("\nѡһ˵(1-3): "); + scanf("%d", &choice); + switch (choice) { + case 1: + printf("ݣ"); + scanf("%d", &year); + printf("·ݣ"); + scanf("%d", &month); + printf("ڣ"); + scanf("%d", &day); + if (isDateValid(year, month, day)) { + int weekday = getWeekday(year, month, day); + switch (weekday) { + case 0: + printf("%d%d%d\n", year, month, day); + break; + case 1: + printf("%d%d%dһ\n", year, month, day); + break; + case 2: + printf("%d%d%dڶ\n", year, month, day); + break; + case 3: + printf("%d%d%d\n", year, month, day); + break; + case 4: + printf("%d%d%d\n", year, month, day); + break; + case 5: + printf("%d%d%d\n", year, month, day); + break; + case 6: + printf("%d%d%d\n", year, month, day); + break; + default: + printf("ִ\n"); + } + } + else { + printf("ڲϷȷ\n"); + } + break; + case 2: + printf("һ: "); + scanf("%d", &year); + if (isLeapYear(year)) { + printf("%d\n", year); + } + else { + printf("%d겻\n", year); + } + break; + case 3: + printf(": "); + scanf("%d", &year); + int format; + printf("ѡʽ1ʾУ2ʾ˫У: "); + scanf("%d", &format); + for (int m = 1; m <= 12; m++) { + printCalendarHeader(m, year); + printCalendarBody(m, year, format,day); + } + break; + default: + printf("\nЧ\n"); + } + printf("\n6:"); + getchar(); // scanfĻз + ifcontinue = getchar(); + if (ifcontinue!= '6') { + break; + } + } + + return 0; +} diff --git a/stu2024/虚拟2401杨博深.c b/stu2024/虚拟2401杨博深.c new file mode 100644 index 0000000..253024c --- /dev/null +++ b/stu2024/虚拟2401杨博深.c @@ -0,0 +1,202 @@ +#define _CRT_SECURE_NO_WARNINGS +#include + + +int menu() { + char g; + int h; + + printf("1. ѯ\n"); + printf("2. ӡ\n"); + printf("x˳\n"); + printf("ѡ"); + scanf(" %c", &g); + if (g >= '1' && g <= '2') { + h = g - '0'; // ַ '1' '2' תΪ 1 2 + } + else if (g == 'x' || g == 'X') { + h = -2; // ʾ˳ + } + else { + h = -1; // ʾЧ + } + return h; +} +//------------------------------------------------------ +int main() { + int n; + int m[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; //һ· + for (;;) { //ѭ + mjq:; + n = menu();//n滻hֵ + if (n == -2) + break; //˳ + else if (n == 1) + { + int year, a = 0, b, i, j; + printf(" · \n-1һ\n"); + scanf("%d", &year); + if (year == -1) + goto mjq;//ҳ + if (year < 0 || year>9999)//Ϸ ֻһۣ + printf("\n\n"); + else { + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) //ж ǵĻ·еĶ»29 + m[2] = 29; + scanf("%d", &m[0]); + scanf("%d", &b); + if (year == 1582 && m[0] == 10 && b > 4 && b < 15) //158210414֮ʱʷϱĸ + printf("\n158210414֮ʱʷϱĸ\n\n"); + else if (year < 0 || m[0] < 0 || m[0]>12 || b < 0 || b>31) { //ݡ·ݺǷЧΧ + printf("\n\n"); + } + else if (m[2] == 28 && b > 28 || m[2] == 29 && b > 29)//Ƿ񳬹˸µ 29 + printf("\n\n"); + else if ((m[0] == 1 || m[0] == 3 || m[0] == 5 || m[0] == 7 || m[0] == 8 || m[0] == 10 || m[0] == 12) && b > 31)//Щ·ֵ31 + printf("\n\n"); + else { + j = b; + if (year == 1582) { + m[10] -= 10; //158210414֮ʱʷϱĸ ȥ + + if (b >= 15) //µ + b -= 10; + } + if (year >= 2000) + a = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400) + 1) % 7;//ӹԪ1굽year-1꣨yearĻ֮ %7㵱ڼ + else a = (year / 100) / 4 - 2 * (year / 100) + year % 100 + (year % 100) / 4 + (13 * 12 / 5); + for (i = 1; i < m[0]; i++) { + b += m[i]; + } + a += b - 1; + a = a % 7; + if (a == 0) + a = 7; //a=0 a + if (year == 1582) { + if (b >= 15) //ͬ + b -= 10; + } + printf("%d%d%d%d\n", year, m[0], j, a); + if (m[2] == 29) + printf("%d\n\n", year); + else printf("%d겻\n", year); + } + } + } + else if (n == 2) + { + int year, a = 0, i, j, b, f; + cxk:; + printf("\n-1һ\n"); + scanf("%d", &year); + if (year == -1) + goto cxk; + if (year < 0 && year > 9999) + printf("\n\n"); + else { + printf("1.\n2.˫\n-1һ\nҪ\n"); + scanf("%d", &n); + if (n == -1) + goto cxk; + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) + m[2] = 29; + if (year >= 2000) + a = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400) + 1) % 7; + else a = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400) + 1) % 7; + if (a == 0) + a = 7; + + if (n == 1) + { + printf("======================%.4d======================\n\n\n", year); //ѯݱͷ + for (i = 1; i <= 12; i++) { + printf("=======================%.2d=======================\n", i); // + printf("һ ڶ \n"); + for (b = 1; b < a; b++) //ÿ¿ŵ + printf(" "); + for (j = 1; j <= m[i]; j++) { + if (year == 1582 && i == 10) { + if (j == 5) //515 + j = 15; + } + printf(" %.2d ", j); + a++; + if (a > 7) { + printf("\n"); + a = 1; + } + }printf("\n"); + } + } + else if (n == 2) { + int x1, x2, x3, x4; + printf("===============================================%.4d===============================================\n\n\n", year); + for (i = 1; i <= 12; i += 2) { + x2 = 1, x3 = 1; + printf("=======================%.2d======================= ", i); //˫ + printf("=======================%.2d=======================\n", i + 1); + printf("һ ڶ "); + printf("һ ڶ \n"); + for (b = 1; b < a; b++) + printf(" "); + f = (a + m[i]) % 7; + if (f == 0) + f = 7; + x1 = 1; + for (j = 1; j <= 40; j++) { + if (j <= m[i]) + printf(" %.2d ", j); + else if (x3 > m[i + 1]) { + break; + } + else printf(" "); + a++; + if (a > 7) { + if (x1 == 1) { + for (b = 1; b < f; b++) + printf(" "); + x1 = 0; + x2 = f, x4 = f; + } + for (x2; x2 <= 38; x2++) { + if (year == 1582 && (i + 1) == 10) { + if (x3 == 5) + x3 = 15; + } + if (x3 <= m[i + 1]) { + printf(" %.2d ", x3); + x3++; + } + x4++; + if (x4 > 7) { + printf("\n"); + + a = 1; + x2++; + x4 = 1; + break; + } + } + } + } + if (year == 1582 && (i + 1) == 10) { + m[10] -= 10; + } + a = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400) + 1) % 7; + int x5; + for (x5 = 1; x5 <= i + 1; x5++) + a += m[x5]; + a = a % 7; + if (a == 0) + a = 7; + printf("\n"); + } + } + else { + printf("\n\n"); + } + } + } + else { printf("\n\n"); } + } +} \ No newline at end of file diff --git a/stu2024/虚拟2402周丛笑.c b/stu2024/虚拟2402周丛笑.c new file mode 100644 index 0000000..3027a59 --- /dev/null +++ b/stu2024/虚拟2402周丛笑.c @@ -0,0 +1,211 @@ +#include + + + +void printfMenu () +{ + printf("1.\n"); + printf("2.˫\n"); +} +//жǷΪ +int isLeapyear(int y) +{ + if(y%4==0&&y%100!=0 || y%400==0) + return 1; + else + return 0; +} +//ڼ㷵ظµ +int daysInMonth(int y, int m) +{ + switch(m){ + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + { + if(y==1582) + { + days=21; + } + } + case 12:days = 31;break; + case 4: + case 6: + case 9: + case 11:days = 30;break; + case 2:{ + if(((year%4) == 0) && ((year%100)!=0) || ((year%400) == 0)){ + days = 29; + }else{ + days = 28; + } + } + } + return days; +} + +//жָڼ +int dayOfWeek(int y, int m, int d) +{ + if(y>1852 && m>10 && d>4)//1582.10.4֮ + { + if (m < 3) + { + m += 12; + y--; + } + int h = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7; + return h + 1; + } + else + { + int K,J,h; + K=y%100; + J=y/100; + switch(m) + { + case 1: + m=3; + break; + case 2: + m=4; + break; + case 3: + m=5; + break; + case 4: + m=6; + break; + case 5: + m=7; + break; + case 6: + m=8; + break; + case 7: + m=9; + break; + case 8: + m=10; + break; + case 9: + m=11; + break; + case 10: + m=12; + break; + case 11: + m=13; + break; + case 12: + m=14; + break; + + } + h=(d+(13*(m+1)/5)+K+K/4+5-J)%7; + switch(h) + { + case 0: + h=6; + break; + case 1: + h=7; + break; + case 2: + h=1; + break; + case 3: + h=2; + break; + case 4: + h=3; + break; + case 5: + h=4; + break; + case 6: + h=5; + break; + } + return h; + } + +} +//ʾָµ +void MonthCalendar(int y, int m, int d) +{ + printf("\tһ\t\t\t\t\t")//\tƱ + int ofday=DaysInMonth(y,m);//ȡÿж + int first_day = dayOfWeek(y, m, 1); //ȡÿ1ܼ + int ofday = daysInMonth(y, m); //ȡһж + int count = first_day; + for (int i = 0; i <= ofday; i++) + { + //ʹܶӦ + if (i == 0) + { + for (int j = 0; j < count % 7; j++) + { + printf("\t"); + } + } + else + { + printf("%2d\t", i); + count++; + } + + //ѭӡһܺ + if (count % 7 == 0) + { + printf("\n"); + } + } + printf("\n"); +} + +//ʾָ year ȫ +void YearCalendar(int y) +{ + int i = 0; + for (i = 1; i <= 12; i++) + { + + MonthCalendar(y, i, day); + printf("\n"); + } + +} + +//֤ǷЧ +int isTureDate(int y, int m, int day) + +int main(void) +{ + int y,m,d,a; + + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n"); + + scanf("%d",&a); + switch(a) + case 1: + scanf("%d",&y); + YearCalendar(y); + case 2: + scanf("%d %d %d",&y,&m,&d); + dayOfWeek(y,m,d); + case 3: + scanf("%d",&y); + isLeapyear(y); + case 4: + default : + printf("롣") + + +} diff --git a/stu2024/虚拟2402康诗曼(1).c b/stu2024/虚拟2402康诗曼(1).c new file mode 100644 index 0000000..07573e9 --- /dev/null +++ b/stu2024/虚拟2402康诗曼(1).c @@ -0,0 +1,173 @@ +#include +#include +int fangbao() +{ + int i; + char x; + printf("1.ѯӦ\n2.ѯ\n3.ѯ2*6ʽ\n4.ѯǷΪ\n5.˳\n"); + scanf(" %c",&x); + if(x=='1') + x=1; + else if(x=='2') + x=2; + else if(x=='3') + x=3; + else if(x=='4') + x=4; + else if(x='5') + x=5; + else + x=6; + return x; +} +int runnian(int year,int month) +{ + int md[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + if((year%4==0&&year%100!=0||year%400==0)&&month==2) + return 29; + else + return md[month]; +} +int date(int year,int month,int day) +{ + int c; + if(month<3) + { + month+=12; + year--; + } + if(year!=1582) + { + int a,b; + a=year/100; + b=year%100; + c=(a/4-2*a+b+b/4+13*(month+1)/5+day-1)%7; + if(c<0) + c+=7; + } + else if(year==1582&&month<=10&&day<=4) + + c=(day+1+2*month+3*(month+1)/5+year+year/4+5)%7; + else if(year==1582&&month>=10&&day>=15) + c=(day+1+2*month+3*(month+1)/5+year+year/4-year/100+year/400)%7; + return c; +} +void yeartb(int year,int month) +{ + int h,j,i; + h=runnian(1582,month); + j=date(1582,month,1); + for(i=0;i=5&&(i-10+j)%7==0) + printf("\n"); + else if(month!=10&&(i+j)%7==0) + printf("\n"); + } + printf("\n"); +} +void monthtwo(int year, int month) +{ + int w,k,e; + w=runnian(year,month); + k=date(year,month,1); + for(e=0;e12||(month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&day>31||(month==4||month==6||month==9||month==11)&&day>30) + printf("\n"); + if((year%4==0&&year%100!=0||year%400==0)&&month==2&&day>29||(year%4!=0&&year%100==0||year%400!=0)&&day>28) + printf("\n"); + if(year==1582) + { + if(month==10&&day>4&&day<15) + printf("\n\n"); + } + m=date(year,month,day); + if(m==0) + printf("Ϊ\n"); + else + printf("Ϊ%d\n",m); + } + if(d==2) + { + int f,g; + printf(":\n"); + scanf("%d",&year); + if(year<0) + printf("\n"); + printf("%4dΪ:\n",year); + for(month=1;month<=12;month++) + { + printf("%d\n",month); + printf(" һ \n"); + if(year!=1582) + monthtwo(year,month); + else + yeartb(year,month); + if(month!=12) + printf("\n"); + } + } + if(d==3) + { + printf(":\n"); + scanf("%d",&year); + if(year<0) + printf("\n"); + printf("%4dΪ:\n",year); + for(month=1;month<=12;month+=2) + { + printf("%d",month); + printf("%d\n",month+1); + printf(" һ "); + printf(" һ \n"); + monthtwo(year,month); + } + } + if(d==4) + { + int year; + printf(":\n"); + scanf("%d",&year); + if(year<0) + printf("\n"); + if(year%4==0&&year%100!=0||year%400==0) + printf("Ϊ\n"); + else + printf("ݲ\n"); + } + } + return 0; +} diff --git a/stu2024/计科2401侯维.cpp b/stu2024/计科2401侯维.cpp new file mode 100644 index 0000000..4dcbed6 --- /dev/null +++ b/stu2024/计科2401侯维.cpp @@ -0,0 +1,389 @@ +#include +using namespace std; +int year, month, day,allday,wannian,con,b,c=0,firstday; +int wannain_month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; +int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; +//ж겢һ +int runyear(int year) +{ + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) + { + return 366; + } + else + { + return 365; + } +} +// չʽ +int week(int y, int m, int d) +{ + if (y < 1582 || y == 1582) { if (m < 10 || (m == 10 && d < 5))d += 3; else if (m == 10 && (4 < d && d < 15))return -1; } + if (m < 3) { y--; m += 12; }return ((d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7 + 1) % 7; +} +void clprintf(int year, int shuchu) { + int yearfirstday, b, con = 0; + int c = 0; + int monthday[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; + yearfirstday = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400) + 1) % 7; + if (year <= 1582) { + yearfirstday = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400) + 11) % 7; + } + if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) + monthday[2] = 29; + if (shuchu == 1) + { + for (int i = 1; i < 13; i++) { + printf("------------------------%2d-------------------------\n", i); + printf("SUM\tMON\tTUE\tWEN\tTHU\tFRI\tSAT\n"); + if (yearfirstday != 0){ + for (int x = 1; x <= yearfirstday; x++) + { + printf("\t"); + } + } + for (int j = 1; j <= monthday[i]; j++) + { + if (year == 1582 && i == 10 && (j > 4 && j < 15)) + { + continue; + } + con += 1; + printf("%d\t", j); + if ((con + yearfirstday) % 7 == 0 || j == monthday[i]) + printf("\n"); + } + yearfirstday = (monthday[i] + yearfirstday) % 7; + con = 0; + printf("\n"); + + } + } + else if (shuchu == 2) + { + con = 0; + int q, m; + for (int i = 1; i < 13; i += 2) + { + printf("------------------------%d------------------------\t", i); + printf("------------------------%d------------------------\n", i + 1); + printf("SUM\tMON\tTUE\tWEN\tTHU\tFRI\tSAT\tSUM\tMON\tTUE\tWEN\tTHU\tFRI\tSAT\n"); + b = (monthday[i] + yearfirstday) % 7; + q = 7 - b + 1; + m = 7 - yearfirstday + 1; + if (yearfirstday != 0) + { + for (int x = 1; x <= yearfirstday; x++) + { + printf("\t"); + } + } + + for (int x = 1; x <= 7 - yearfirstday; x++) + { + printf("%d\t", x); + } + if (year == 1582 && i + 1 == 10) + { + printf("\t1\t2\t3\t4\t15\t16\t"); + q = 17; + } + else + { + if (b != 0) + { + for (int x = 1; x <= b; x++) + { + printf("\t"); + } + } + for (int y = 1; y <= 7 - b; y++) + { + printf("%d\t", y); + } + } + printf("\n"); + + for (int j = m; j <= monthday[i]; j++) + { + + printf("%d\t", j); + + if (j == monthday[i] && (j + yearfirstday) % 7 != 0) + { + for (int g = 0; g <= 7 - b - 1; g++) + { + printf("\t"); + } + } + if ((j + yearfirstday) % 7 == 0 || j == monthday[i]) + { + for (int y = q; y <= monthday[i + 1]; y++) + { + printf("%d\t", y); + if (year == 1582 && (i + 1) == 10) + { + if (y == 23 || y == 30 || y == 31) + { + q = y + 1; + printf("\n"); + break; + } + else + continue; + } + else + { + if (((y + b) % 7 == 0 || y == monthday[i + 1]) && j!=monthday[i]) + { + q = y + 1; + printf("\n"); + break; + } + else if (j == monthday[i] && (y + b) % 7 == 0 && y != monthday[i + 1]) + { + q = y + 1; + printf("\n\t\t\t\t\t\t\t"); + continue; + } + } + } + } + if (j == monthday[i] && q != monthday[i + 1]) + { + /*for (int flag = q; flag <= monthday[i + 1]; flag++) + { + printf("%d\t", flag); + break; + }*/ + printf("\n"); + } + if (year == 1582 && i == 9 && j == 29) + printf("\n"); + } + yearfirstday = (monthday[i + 1] + b) % 7; + printf("\n"); + + } + } +} +#include +#include + +void checkFestival(int year, int month, int day) { + // Ԫ + if (month == 1 && day == 1) { + printf("Ԫ\n"); + return; + } + + // ڣ򵥼ڹ121127գʵӦũ׼ȷжϣ + if (month == 1 && (21 <= day && day <= 27)) { + printf("\n"); + return; + } + + // ڣһڹ4446֮䣬45Ϊ + if (month == 4 && day == 5) { + printf("\n"); + return; + } + + // Ͷڣ51 + if (month == 5 && day == 1) { + printf("Ͷ\n"); + return; + } + + // ڣ򵥼ڹ610ңʵӦũ׼ȷжϣ + if (month == 6 && day == 10) { + printf("\n"); + return; + } + + // ڣ򵥼ڹ917ңʵӦũ׼ȷжϣ + if (month == 9 && day == 17) { + printf("\n"); + return; + } + + // ڣ101 + if (month == 10 && day == 1) { + printf("\n"); + return; + } + + printf("\n"); +} +int main() +{ + cout << "\033[1;31;47m1ѯϢ \033[0m" << '\n' << "\033[1;32;47m2ѯݵ \033[0m" << '\n' << "\033[1;30;47m3ѯǷΪ \033[0m" << '\n' << "\033[1;34;47m4˳ \033[0m" << '\n'; + int a; cin >> a; + if (cin.fail() || a < 1 || a > 4) + { + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + switch (a) + { + case 1: + { + cout << "ѯ( գ:2024 11 11) :"; + cin >> year >> month >> day; + if (cin.fail() || month < 1 || month > 12) + { + + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + if (cin.fail() || day < 1 || (month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&day>31 || (month==4||month==6||month==9||month==11)&&day>30||(runyear(year)==366)&&(month==2)&&day>29|| (runyear(year) == 365) && (month == 2) && day > 28) + { + + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + if (cin.fail() || year==1582&&month==10&&(day>4&&day<15)) + { + + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + if (cin.fail() || year < 0 || year > 999999) + { + + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + int cinday; + cinday = week(year, month, day); + switch (cinday) + { + case 0: cout << year << "" << month << "" << day << "" << "" << '\n' << '\n'; break; + case 1: cout << year << "" << month << "" << day << "" << "һ" << '\n' << '\n'; break; + case 2: cout << year << "" << month << "" << day << "" << "ڶ" << '\n' << '\n'; break; + case 3: cout << year << "" << month << "" << day << "" << "" << '\n' << '\n'; break; + case 4: cout << year << "" << month << "" << day << "" << "" << '\n' << '\n'; break; + case 5: cout << year << "" << month << "" << day << "" << "" << '\n' << '\n'; break; + case 6: cout << year << "" << month << "" << day << "" << "" << '\n' << '\n'; break; + } + cout << '\n' << '\n'; + main(); + } + case 2: + { + cout << "1." << '\n' << "2.˫" << '\n'; + int b; cin >> b; + if (cin.fail() || b < 1 || b > 2) { + + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + switch (b) + { + case 1: + { + cout << "ѯ :"; + cin >> wannian; + if (cin.fail() || wannian < 0 || wannian > 99999) { + + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + clprintf(wannian, 1); + break; + } + case 2: + { + cout << "ѯ :"; + cin >> wannian; + if (cin.fail() || wannian < 0 || wannian > 10000) { + + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + clprintf(wannian, 2); + break; + } + } + main(); + } + case 3: + { + cout << "ѯ :"; + cin >> year; + if (cin.fail() || year < 0 || year > 99999) { + + cin.clear(); // ״̬ + cin.ignore(numeric_limits::max(), '\n'); // Դ + cout << "\033[31mǷ룡\033[0m" << '\n'; + main(); + } + if (runyear(year) == 366) + cout << year << "" << '\n' << '\n'; + else + cout << year << "겻" << '\n' << '\n'; + } + main(); + case 4: + { + int y, m, d; + cout << "ѯڼ" << '\n'; + cin >> y >> m >> d; + checkFestival(y, m, d); + } + case 5: + cout << "\033[31m˳uit˧˵ĸ\033[0m" << '\n'; + string shuai; + cin >> shuai; + if (shuai == "lxm" || shuai == "tl" || shuai == "zsk") + { + cout << "\033[33m\033[0m" << '\n'; return 0; + } + else if (shuai == "gxk") + { + cout << "\033[33mҸ߸˧ô\033[0m" << '\n'; return 0; + } + else if (shuai == "yxx") + { + cout << "\033[33mСС˧ô\033[0m" << '\n'; return 0; + } + else if (shuai == "mzn") + { + cout << "\033[33m˧ô\033[0m" << '\n'; return 0; + } + else if (shuai == "lcm") + { + cout << "\033[33m½˧ô\033[0m" << '\n'; return 0; + } + else if (shuai == "djy") + { + cout << "\033[33m(sͷ\033[0m" << '\n'; + cin >> shuai; + if (shuai == "sys") + cout << "\033[33m\033[0m" << '\n'; return 0; + } + else + { + cout << "\033[33m\033[0m" << '\n'; + main(); + } + return 0; + } + return 0; +} \ No newline at end of file diff --git a/stu2024/计科2401孙美琪.c b/stu2024/计科2401孙美琪.c new file mode 100644 index 0000000..d18b5ef --- /dev/null +++ b/stu2024/计科2401孙美琪.c @@ -0,0 +1,368 @@ +#include +void Monthhead(int month) +{ + + printf("%s\n",(month==1)?"Jan":(month==2)?"Feb":(month==3)?"Mar":(month==4)?"Apr":(month==5)?"May":(month==6)?"Jun":(month==7)?"Jul":(month==8)?"Aug":(month==9)?"Sep":(month==10)?"Oct":(month==11)?"Nov":"Dec"); + return; +} +void dayHead() +{ + printf(" Sun Mon Tue Med Thu Fri Sat\n"); + return; +} +int firstDay(int year) +{ + int b=(year-1)*365+(year-1)*400+(year-1)*4-(year-1)*100+1; + return b%7; +} +int Week6(int year,int month) +{ + int w,c,y; + int day=1; + if(month<3) + { + month+=12; + year--; + } + c=year/100; + y=year%100; + w=(c/4-2*c+y+y/4+13*(month+1)/5+day-1)%7; + return w; +} +int Week(int year,int month,int day) +{ + int w,c,y; + if(year<=1582&&month<=10&&day<15) + { + if(month<3) + { + month+=12; + year--; + } + day-=4; + c=year/100; + y=year%100; + w=(c/4-2*c+y+y/4+13*(month+1)/5+day-1)%7; + }else{ + if(month<3) + { + month+=12; + year--; + } + c=year/100; + y=year%100; + w=(c/4-2*c+y+y/4+13*(month+1)/5+day-1)%7; + } + + return w; +} +int isLeapYear(int year) +{ +return (year%4==0&&year%100!=0)||year%400==0; + +} +int DayMonth(int year,int month) +{ + + if(month==2) + { + if(isLeapYear(year)) + { + return 29; + }else{ + return 28; + } + }else if(month==4||month==6||month==9||month==11){ + return 30; + }else{ + return 31; + } +} +void printCalendar3(int year) +{ + int first=firstDay(year); + int month,day; + for(month=1;month<=9;month++) + { + printf("\n"); + Monthhead(month); + dayHead(); + for(day=1;day<=first;day++) + printf(" "); + int dayMonth=DayMonth(year,month); + for(day=1;day<=dayMonth;day++) + { + printf("%4d",day); + if((day+first)%7==0) + { + printf("\n"); + } + } + if((day+first)%7!=0) + { + printf("\n"); + } + first=(first+dayMonth)%7; + } + for(month=10;month<=12;month++) + { + int i; + + + day=1; + if(month==10) + { + int a[21]={1,2,3,4,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; + Monthhead(month); + dayHead(); + + int first2=Week(year,month,day); + for(i=1;i<=first2;i++) + printf(" "); + for(i=0;i<21;i++) + { + printf("%4d",a[i]); + if((i+first2+1)%7==0) + { + printf("\n"); + } + } + if((i+first2)%7!=0) + { + printf("\n"); + } + first2=(first2+21)%7; + continue; + } + printf("\n"); +int first3=Week(year,month,day); + Monthhead(month); + dayHead(); + for(i=1;i<=first3;i++) + printf(" "); + int dayMonth; + if(month==11){ + dayMonth=30; + }else if(month==12){ + dayMonth=31; + } + for(i=1;i<=dayMonth;i++) + { + printf("%4d",i); + if((i+first3)%7==0) + { + printf("\n"); + } + } + if((i+first3)%7!=0) + { + printf("\n"); + } + first3=(first3+dayMonth)%7; + + + } + printf("\n"); +} +void printCalendar(int year) +{ + int first=firstDay(year); + int month,day; + for(month=1;month<=12;month++) + { + Monthhead(month); + dayHead(); + for(day=1;day<=first;day++) + printf(" "); + int dayMonth=DayMonth(year,month); + for(day=1;day<=dayMonth;day++) + { + printf("%4d",day); + if((day+first)%7==0) + { + printf("\n"); + } + } + if((day+first)%7!=0) + { + printf("\n"); + } + first=(first+dayMonth)%7; + } +} +long int f(int year,int month) + +{ + +if(month<3) return year-1; + +else return year; + +} + +long int g(int month) + +{ + +if(month<3) return month+13; + +else return month+1; + +} + +long int n(int year,int month,int day) + +{ + +return 1461L*f(year,month)/4+153L*g(month)/5+day; + +} + +int w(int year,int month,int day) + +{ + +return(int) ((n(year,month,day)%7-621049L%7+7)%7); + +} + +int date[12][6][7]; + +int day_tbl[ ][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}}; + +int Double(int year) +{ + +int sw,leap,i,j,k,wd,day; + +char title[]="SUM MON TUE WED THU FRI SAT"; + +sw=w(year,1,1); + +leap=(year%4==0&&year%100!=0)||year%400==0; + +for(i=0;i<12;i++) + +for(j=0;j<6;j++) + +for(k=0;k<7;k++) + +date[i][j][k]=0; + +for(i=0;i<12;i++) + +for(wd=0,day=1;day<=day_tbl[leap][i];day++) + +{ + +date[i][wd][sw]=day; + +sw=++sw%7; +if(sw==0) wd++; + +} + +printf("\n================== The Calendar of Year %d==================\n",year); + +for(i=0;i<6;i++) + +{ + +for(wd=0,k=0;k<7;k++) + +wd+=date[i][5][k]+date[i+6][5][k]; + +wd=wd?6:5; + +printf("%2d %s %2d %s\n",i+1,title,i+7,title); + +for(j=0;j<6;j++) +{ + +/*printf(" ");*/ + +for(k=0;k<7;k++) + +if(date[i][j][k]) + +printf("%5d",date[i][j][k]); + +else printf(" "); + +printf(" "); + + +for(k=0;k<7;k++) + +if(date[i+6][j][k]) + +printf("%5d",date[i+6][j][k]); + +else printf(" "); + +printf("\n"); + +} +} +} + + +void choiceCalendar(int year) +{ + + int choose; + while(1){printf("1.\n2.˫\n"); + scanf("%d",&choose); + switch(choose){ + case 1: if(year!=1582) + { + printCalendar(year); + }else if(year==1582){ + printCalendar3(year); + } + break; + case 2:Double(year); + break; + default: + printf("д\n"); + break; + }break; +} +} + +int main() +{ + int choice,year,month,day; + while(1) + { + printf("1.ij\n2.ڼ\n3.ж\n4.˳\n"); + printf("ѡĸ!\n"); + scanf("%d",&choice); + switch(choice){ + case 1:printf(":\n"); + scanf("%d",&year); + choiceCalendar(year); + break; + case 2:printf("ijijij(ո):\n"); + scanf("%d %d %d",&year,&month,&day); + int w=Week(year,month,day); + printf("%d\n",w); + break; + case 3:printf(":\n"); + scanf("%d",&year); + if(isLeapYear(year)){ + printf("YES\n"); + }else{ + printf("NO\n"); + } + break; + case 4: return 0; + break; + default:printf("Чѡ\n"); + break; + + } + } + return 0; + +} diff --git a/stu2024/计科2401常迦鑫.cpp b/stu2024/计科2401常迦鑫.cpp new file mode 100644 index 0000000..16ced68 --- /dev/null +++ b/stu2024/计科2401常迦鑫.cpp @@ -0,0 +1,601 @@ +#include +using namespace std; +#include +#include +#include +int run (int n) +{ + if(n%400==0||(n%4==0&&n%100!=0)) + { + return 1; + } + return 0; +} +int rq (int n,int y,int r) +{ + if (y <= 2) + { + y += 12; + n--; + } + int k = n % 100; + int j = n / 100; + int h = (r + 13 * (y + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; + if (y > 12) + { + y -= 12; + n++; + } + h--; + if(h==-1) + { + h=6; + } + if((n==1582&&y==10&&r<=4)||(n==1582&&y<10)||(n<1582)) + { + switch(h) + { + case 6:h=2;break; + case 5:h=1;break; + case 4:h=0;break; + case 3:h=6;break; + case 2:h=5;break; + case 1:h=4;break; + case 0:h=3;break; + } + } + return h; +} +int dy (int n,int y) +{ + if(y==1||y==3||y==5||y==7||y==8||y==10||y==12) + { + return 31; + }else if(y==2) + { + if(run(n)) + { + return 29; + } + return 28; + }else + return 30; +} +int main() +{ + while(1) + { + for(int f=1000;f>=0;f--) + { + cout<>a; + if(a=="1") + { + int year, month, day; + for(int i=1000;i>=0;i--) + { + cout<> year >> month >> day; + if(month>12||day>31) + { + goto wen; + } + char week[8][10] = {"","һ","ܶ","","","",""}; + int h=rq(year,month,day); + for(int f=1000;f>=0;f--) + { + cout<=0;i--) + { + cout<>n; + cout<=0;i--) + { + cout<=0;i--) + { + cout<=0;i--) + { + cout<>e; + if(e=="1") + { + for(int i=1000;i>=0;i--) + { + cout<>year1; + if(year1!=1582){ + + char week1[8][10] = {"","һ","ܶ","","","",""}; + char yue[20][20] = {"һ","","","","","","","","","ʮ","ʮһ","ʮ"}; + for(int i=0;i<12;i++) + { + cout<<" "<=0;f--) + { + cout<>year1; + if(year1!=1582){ + + char week1[8][10] = {"","һ","ܶ","","","",""}; + char yue[20][20] = {"һ","","","","","","","","","ʮ","ʮһ","ʮ"}; + for(int i=0;i<12;i+=2) + { + int ttt; + cout<<" "<=10) + { + cout<=10) + { + cout<=0;i--) + { + cout<=0;i--) + { + cout<>b; + if(b=="1") + { + continue; + }else if(b=="2") + { + break; + }else + { + + for(int i=1000;i>=0;i--) + { + cout<=0;i--) + { + cout< +int main(void) +{ + int x; + int j; + printf("1.ѯijijڼжǷΪ\n"); + printf("2.ӡ\n"); + printf("3.ӡ˫\n"); + printf("4.˳\n"); + scanf("%d",&x); + int year; + int month; + int day; + int week; + int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + int c; + int y; + int k=1; + int a=2; + int dayss=1; + switch(x) + { + case 1: + scanf("%d-%d-%d",&year,&month,&day); + if(((year%4==0)&&(year%100!=0))||(year%400==0)) + { + days[2]=29; + printf("\n"); + } else printf("ƽ\n"); + if((month==1&&day<=31)||(days[2]==29&&month==2&&day<=29)||(days[2]==28&&month==2&&day<=28)||(month==3&&day<=31)||(month==4&&day<=30)|| + (month==5&&day<=31)||(month==6&&day<=30)||(month==7&&day<=31)||(month==8&&day<=31)||(month==9&&day<=30)||(year!=1582&&month==10&&day<=31)||(month==11&&day<=30)|| + (month==12&&day<=31)||(year==1582&&month==10&&day!=5&&day!=6&&day!=7&&day!=8&&day!=9&&day!=10&&day!=11&&day!=12&&day!=13&&day!=14)) + { + if (month == 1 || month == 2) + year--, month += 12; + c = year / 100; + y = year - c * 100; + if(year>1582) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else if(year==1582&&month>10) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else if((year==1582&&month==10)&&day>4) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else + week=(day+1+2*month+3*(month+1)/5+year+year/4+5)%7; + if(month==13||month==14) + year++; + while(week < 0) + week += 7; + week %= 7; + switch (week) + { + case 1:printf("һ\n"); break; + case 2:printf("ڶ\n"); break; + case 3:printf("\n"); break; + case 4:printf("\n"); break; + case 5:printf("\n"); break; + case 6:printf("\n"); break; + case 0:printf("\n"); break; + }break; + } + else printf(""); + case 2: + scanf("%d-%d-%d",&year,&month,&day); + if((month==1&&day<=31)||(days[2]==29&&month==2&&day<=29)||(days[2]==28&&month==2&&day<=28)||(month==3&&day<=31)||(month==4&&day<=30)|| + (month==5&&day<=31)||(month==6&&day<=30)||(month==7&&day<=31)||(month==8&&day<=31)||(month==9&&day<=30)||(year!=1582&&month==10&&day<=31)||(month==11&&day<=30)|| + (month==12&&day<=31)||(year==1582&&month==10&&day!=5&&day!=6&&day!=7&&day!=8&&day!=9&&day!=10&&day!=11&&day!=12&&day!=13&&day!=14)) + { + for( j=1;j<=12;j++) + { + month=j; + printf("\n"); + printf("%d \n",month); + printf(" һ ܶ \n"); + if (month == 1 || month == 2) + year--, month += 12; + c = year / 100; + y = year - c * 100; + if(year>1582) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else if(year==1582&&month>10) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else if((year==1582&&month==10)&&day>4) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else + week=(1+1+2*month+3*(month+1)/5+year+year/4+5)%7; + if(month==13||month==14) + year++; + while(week < 0) + week += 7; + week %= 7; + if(year==1582&&month==10) + week=1; + switch (week) + { + case 1:printf(" "); break; + case 2:printf(" "); break; + case 3:printf(" "); break; + case 4:printf(" "); break; + case 5:printf(" "); break; + case 6:printf(" "); break; + } + for(day=1;day<=days[j];day++) + { + month=j; + while((year==1582&&month==10)&&(day==5||day==6||day==7||day==8||day==9||day==10||day==11||day==12||day==13||day==14)) + day++; + if (month == 1 || month == 2) + year--, month += 12; + c = year / 100; + y = year - c * 100; + if(year>1582) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else if(year==1582&&month>10) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else if((year==1582&&month==10)&&day>4) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else + week=(day+1+2*month+3*(month+1)/5+year+year/4+5)%7; + if(month==13||month==14) + year++; + while(week < 0) + week += 7; + week %= 7; + if(week==6) + printf("%2d\n",day); + else + printf("%2d ",day); + } + }break; + }else printf(""); + case 3: + scanf("%d-%d-%d",&year,&month,&day); + if((month==1&&day<=31)||(days[2]==29&&month==2&&day<=29)||(days[2]==28&&month==2&&day<=28)||(month==3&&day<=31)||(month==4&&day<=30)|| + (month==5&&day<=31)||(month==6&&day<=30)||(month==7&&day<=31)||(month==8&&day<=31)||(month==9&&day<=30)||(year!=1582&&month==10&&day<=31)||(month==11&&day<=30)|| + (month==12&&day<=31)||(year==1582&&month==10&&day!=5&&day!=6&&day!=7&&day!=8&&day!=9&&day!=10&&day!=11&&day!=12&&day!=13&&day!=14)) + { + for( j=1;j<=12;j+=2) + {day=1; + month=j; + printf("\n"); + printf("%d %d\n",month,month+1); + printf(" һ ܶ һ ܶ \n"); + if (month == 1 || month == 2) + year--, month += 12; + c = year / 100; + y = year - c * 100; + if(year>1582) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else if(year==1582&&month>10) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else if((year==1582&&month==10)&&day>4) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else + week=(1+1+2*month+3*(month+1)/5+year+year/4+5)%7; + if(month==13||month==14) + year++; + while(week < 0) + week += 7; + week %= 7; + if(year==1582&&month==10) + week=1; + switch (week) + { + case 1:printf(" "); break; + case 2:printf(" "); break; + case 3:printf(" "); break; + case 4:printf(" "); break; + case 5:printf(" "); break; + case 6:printf(" "); break; + } + + + for(;day<=days[k];day++) + { + month=k; + while((year==1582&&month==10)&&(day==5||day==6||day==7||day==8||day==9||day==10||day==11||day==12||day==13||day==14)) + day++; + if (month == 1 || month == 2) + year--, month += 12; + c = year / 100; + y = year - c * 100; + if(year>1582) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else if(year==1582&&month>10) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else if((year==1582&&month==10)&&day>4) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; + else + week=(day+1+2*month+3*(month+1)/5+year+year/4+5)%7; + if(month==13||month==14) + year++; + while(week < 0) + week += 7; + week %= 7; + if(week!=6) + printf("%2d ",day); + else + { + printf("%2d ",day); + for( ;a<=12;a+=2) + { + month=a; + if (month == 1 || month == 2) + year--, month += 12; + c = year / 100; + y = year - c * 100; + if(year>1582) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else if(year==1582&&month>10) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else if((year==1582&&month==10)&&day>4) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + 1 - 1; + else + week=(1+1+2*month+3*(month+1)/5+year+year/4+5)%7; + if(month==13||month==14) + year++; + while(week < 0) + week += 7; + week %= 7; + if(year==1582&&month==10) + week=1; + switch (week) + { + case 1:printf(" "); break; + case 2:printf(" "); break; + case 3:printf(" "); break; + case 4:printf(" "); break; + case 5:printf(" "); break; + case 6:printf(" "); break; + }} + for(;dayss<=days[a];dayss++) + { + month=a; + while((year==1582&&month==10)&&(dayss==5||dayss==6||dayss==7||dayss==8||dayss==9||dayss==10||dayss==11||dayss==12||dayss==13||dayss==14)) + dayss++; + if (month == 1 || month == 2) + year--, month += 12; + c = year / 100; + y = year - c * 100; + if(year>1582) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + dayss - 1; + else if(year==1582&&month>10) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + dayss - 1; + else if((year==1582&&month==10)&&day>4) + week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + dayss - 1; + else + week=(dayss+1+2*month+3*(month+1)/5+year+year/4+5)%7; + + if(month==13||month==14) + year++; + while(week < 0) + week += 7; + week %= 7; + if(week==6) + {printf("%2d\n",dayss);continue;} + else + printf("%2d ",dayss); + } + + } + } + } + break; + case 4: + break; + default: printf(""); + break; + } + } + return 0; +} diff --git a/stu2024/计科2401高在毅(1).cpp b/stu2024/计科2401高在毅(1).cpp new file mode 100644 index 0000000..8d4144f --- /dev/null +++ b/stu2024/计科2401高在毅(1).cpp @@ -0,0 +1,1380 @@ +#include +using namespace std; +int w; +int weekjudge(int d, int m, int y) +{ + if (m == 1 || m == 2) + { + m = (m == 1 ? 13 : 14); + y--; + } + w = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400 + 1) % 7; + if ((y < 1582) || (y == 1582 && m < 10) || (y == 1582 && m == 10 && d <= 4)) + { + switch (w) + { + case 1: + w = 4; + break; + case 2: + w = 5; + break; + case 3: + w = 6; + break; + case 4: + w = 0; + break; + case 5: + w = 1; + break; + case 6: + w = 2; + break; + case 0: + w = 3; + break; + } + } + return w; +} +int yearjudge(int y) +{ + if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) + return 1; + else + return 0; +} +int main() +{ +start: + cout << "1.ڣѯӦԼǷΪ" << endl; + cout << "2.ݣʾӦ" << endl; + cout << "3.˳" << endl << endl; + string a; + cin >> a; + //1.ڣѯӦԼǷΪ + if (a == "1") + { + int y, m, d, c; + on1: + double g; + cout << "ݣ" << endl; + cin >> g; + y = static_cast(g); + if (y < 0 || cin.fail() || y != g) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto on1; + } + on2: + cout << "·ݣ" << endl; + cin >> g; + m = static_cast(g); + if (m < 1 || m > 12 || cin.fail() || m != g) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto on2; + } + on3: + int h; + h = yearjudge(y); + cout << "ڣ" << endl; + cin >> g; + d = static_cast(g); + if (h == 1 && m == 2 && (d < 1 || d > 29 || cin.fail() || d != g)) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto on3; + } + else if (h == 0 && m == 2 && (d < 1 || d > 28 || cin.fail() || d != g)) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto on3; + } + else if ((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && (d < 1 || d > 31 || cin.fail() || d != g)) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto on3; + } + else if ((m == 4 || m == 6 || m == 9 || m == 11) && (d < 1 || d > 30 || cin.fail() || d != g)) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto on3; + } + else if (y == 1582 && m == 10 && (d < 1 || (d > 4 && d < 15) || d>31 || cin.fail() || d != g)) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto on3; + } + c = weekjudge(d, m, y); + switch (c) + { + case 0: + cout << y << "" << m << "" << d << "Ϊ" << endl; + break; + case 1: + cout << y << "" << m << "" << d << "Ϊһ" << endl; + break; + case 2: + cout << y << "" << m << "" << d << "Ϊڶ" << endl; + break; + case 3: + cout << y << "" << m << "" << d << "Ϊ" << endl; + break; + case 4: + cout << y << "" << m << "" << d << "Ϊ" << endl; + break; + case 5: + cout << y << "" << m << "" << d << "Ϊ" << endl; + break; + case 6: + cout << y << "" << m << "" << d << "Ϊ" << endl; + break; + } + if (yearjudge(y) == 1) + cout << y << "" << endl << endl; + else if(yearjudge(y) == 0) + cout << y << "겻" << endl << endl; + goto start; + } + //2.ݣʾӦ + else if (a == "2") + { + int l, b, y; + in1: + double g; + cout << "ݣ" << endl; + cin >> g; + l = static_cast(g); + if (l < 0 || cin.fail() || l != g) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto in1; + } + in2: + cout << "ѡʽ" << endl; + cout << "1." << endl; + cout << "2.˫" << endl; + cin >> g; + b = static_cast(g); + if ((b != 1 && b != 2)|| cin.fail() || b != g) + { + cin.clear(); + cin.ignore(numeric_limits::max(), '\n'); + cout << "" << endl; + goto in2; + } + //1. + if (b == 1) + { + int k; + y = l; + if (yearjudge(y) == 1) + k = 29; + else + k = 28; + cout << "\t " << y << endl; + int m, d; + for (int i = 1; i <= 12; i++) + { + y = l; + if (i == 1) + cout << " January" << endl; + if (i == 2) + cout << " February" << endl; + if (i == 3) + cout << " March" << endl; + if (i == 4) + cout << " April" << endl; + if (i == 5) + cout << " May" << endl; + if (i == 6) + cout << " June" << endl; + if (i == 7) + cout << " July" << endl; + if (i == 8) + cout << " August" << endl; + if (i == 9) + cout << " September" << endl; + if (i == 10) + cout << " October" << endl; + if (i == 11) + cout << " November" << endl; + if (i == 12) + cout << " December" << endl; + cout << "Sun Mon Tue Wed Thu Fri Sat" << endl; + m = i; + d = 1; + int c = weekjudge(d, m, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) + { + m = i; + for (int j = 1; j <= 31; j++) + { + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < 32) + { + cout << j << " "; + } + int c = weekjudge(d, m, y); + if (c == 6 && d != 31) + { + cout << endl; + if (j < 9) + { + cout << " "; + } + else if (j >= 9 && j < 32) + { + cout << " "; + } + } + if (y == 1582 && m == 10 && j == 4) + { + cout << "\b"; + j = 14; + d = 15; + continue; + } + d++; + } + cout << endl; + } + else if (i == 4 || i == 6 || i == 9 || i == 11) + { + m = i; + for (int j = 1; j <= 30; j++) + { + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < 31) + { + cout << j << " "; + } + int c = weekjudge(d, m, y); + if (c == 6 && d != 30) + { + cout << endl; + if (j < 9) + { + cout << " "; + } + else if (j >= 9 && j < 31) + { + cout << " "; + } + } + d++; + } + cout << endl; + } + else + { + m = i; + for (int j = 1; j <= k; j++) + { + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < k+1) + { + cout << j << " "; + } + int c = weekjudge(d, m, y); + if (c == 6 && d != k) + { + cout << endl; + if (j < 9) + { + cout << " "; + } + else if (j >= 9 && j < k+1) + { + cout << " "; + } + } + d++; + } + cout << endl; + } + } + goto start; + } + //2.˫ + else if (b == 2) + { + int k; + y = l; + if (yearjudge(y) == 1) + k = 29; + else + k = 28; + cout << "\t " << y << endl; + int i = 1, j = 1; + int m1, m2, d1, d2; + cout << " January February" << endl; + cout << "Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat" << endl; + d1 = 1; + m1 = 1; + d2 = 1; + m2 = 2; + int c = weekjudge(d1, m1, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + for (i; i <= 31; i++) + { + if (i >= 1 && i < 9) + { + cout << i << " "; + } + else if (i >= 9 && i < 32) + { + cout << i << " "; + } + int c = weekjudge(d1, m1, y); + if (c == 6) + { + if (i >= 1 && i < 10) + { + cout << " "; + } + else if (i >= 10 && i < 32) + { + cout << " "; + } + if (j < 10 && j != 1) + { + cout << " "; + } + else if (j >= 10 && j < k+1) + { + cout << " "; + } + if (i == 9 && c == 6) + { + cout << " "; + } + for (j; j <= k; j++) + { + if (j == 1) + { + int c = weekjudge(d2, m2, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + } + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < k+1) + { + cout << j << " "; + } + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != k) + { + j++; + d2++; + cout << endl; + break; + } + if (j == k) + { + cout << endl; + } + d2++; + } + if (i < 9) + { + cout << " "; + } + else if (i >= 9 && i < 32) + { + cout << " "; + } + } + d1++; + if (i == 31) + { + d1 = 31; + int c = weekjudge(d1, m1, y); + if (c == 0) + cout << " "; + if (c == 1) + cout << " "; + if (c == 2) + cout << " "; + if (c == 3) + cout << " "; + if (c == 4) + cout << " "; + if (c == 5) + cout << " "; + if (c == 6) + cout << " "; + cout << " "; + for (j; j <= k; j++) + { + cout << j << " "; + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != k) + { + cout << endl; + cout << " "; + } + d2++; + } + } + } + cout << endl; + cout << " March April" << endl; + cout << "Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat" << endl; + i = 1, j = 1, d1 = 1, d2 = 1, m1 = 3, m2 = 4; + c = weekjudge(d1, m1, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + for (i; i <= 31; i++) + { + if (i >= 1 && i < 9) + { + cout << i << " "; + } + else if (i >= 9 && i < 32) + { + cout << i << " "; + } + int c = weekjudge(d1, m1, y); + if (c == 6) + { + if (i >= 1 && i < 10) + { + cout << " "; + } + else if (i >= 10 && i < 32) + { + cout << " "; + } + if (j < 10 && j != 1) + { + cout << " "; + } + else if (j >= 10 && j < 31) + { + cout << " "; + } + if (i == 9 && c == 6) + { + cout << " "; + } + for (j; j <= 30; j++) + { + if (j == 1) + { + int c = weekjudge(d2, m2, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + } + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < 31) + { + cout << j << " "; + } + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 30) + { + j++; + d2++; + cout << endl; + break; + } + if (j == 30) + { + cout << endl; + } + d2++; + } + if (i < 9) + { + cout << " "; + } + else if (i >= 9 && i < 32) + { + cout << " "; + } + } + d1++; + if (i == 31 && d2 != 30) + { + d1 = 31; + int c = weekjudge(d1, m1, y); + if (c == 0) + cout << " "; + if (c == 1) + cout << " "; + if (c == 2) + cout << " "; + if (c == 3) + cout << " "; + if (c == 4) + cout << " "; + if (c == 5) + cout << " "; + if (c == 6) + cout << " "; + cout << " "; + for (j; j <= 30; j++) + { + cout << j << " "; + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 30) + { + cout << endl; + cout << " "; + } + d2++; + } + } + } + cout << endl; + cout << " May June" << endl; + cout << "Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat" << endl; + i = 1, j = 1, d1 = 1, d2 = 1, m1 = 5, m2 = 6; + c = weekjudge(d1, m1, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + for (i; i <= 31; i++) + { + if (i >= 1 && i < 9) + { + cout << i << " "; + } + else if (i >= 9 && i < 32) + { + cout << i << " "; + } + int c = weekjudge(d1, m1, y); + if (c == 6) + { + if (i >= 1 && i < 10) + { + cout << " "; + } + else if (i >= 10 && i < 32) + { + cout << " "; + } + if (j < 10 && j != 1) + { + cout << " "; + } + else if (j >= 10 && j < 31) + { + cout << " "; + } + if (i == 9 && c == 6) + { + cout << " "; + } + for (j; j <= 30; j++) + { + if (j == 1) + { + int c = weekjudge(d2, m2, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + } + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < 31) + { + cout << j << " "; + } + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 30) + { + j++; + d2++; + cout << endl; + break; + } + if (j == 30) + { + cout << endl; + } + d2++; + } + if (i < 9) + { + cout << " "; + } + else if (i >= 9 && i < 32) + { + cout << " "; + } + } + d1++; + if (i == 31 && d2 != 30) + { + d1 = 31; + int c = weekjudge(d1, m1, y); + if (c == 0) + cout << " "; + if (c == 1) + cout << " "; + if (c == 2) + cout << " "; + if (c == 3) + cout << " "; + if (c == 4) + cout << " "; + if (c == 5) + cout << " "; + if (c == 6) + cout << " "; + cout << " "; + for (j; j <= 30; j++) + { + cout << j << " "; + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 30) + { + cout << endl; + cout << " "; + } + d2++; + } + } + } + cout << endl; + cout << " July August" << endl; + cout << "Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat" << endl; + i = 1, j = 1, d1 = 1, d2 = 1, m1 = 7, m2 = 8; + c = weekjudge(d1, m1, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + for (i; i <= 31; i++) + { + if (i >= 1 && i < 9) + { + cout << i << " "; + } + else if (i >= 9 && i < 32) + { + cout << i << " "; + } + int c = weekjudge(d1, m1, y); + if (c == 6) + { + if (i >= 1 && i < 10) + { + cout << " "; + } + else if (i >= 10 && i < 32) + { + cout << " "; + } + if (j < 10 && j != 1) + { + cout << " "; + } + else if (j >= 10 && j < 32) + { + cout << " "; + } + if (i == 9 && c == 6) + { + cout << " "; + } + for (j; j <= 31; j++) + { + if (j == 1) + { + int c = weekjudge(d2, m2, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + } + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < 32) + { + cout << j << " "; + } + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 31) + { + j++; + d2++; + cout << endl; + break; + } + if (j == 31) + { + cout << endl; + } + d2++; + } + if (i < 9) + { + cout << " "; + } + else if (i >= 9 && i < 32) + { + cout << " "; + } + } + d1++; + if (i == 31 && d2 != 31) + { + d1 = 31; + int c = weekjudge(d1, m1, y); + if (c == 0) + cout << " "; + if (c == 1) + cout << " "; + if (c == 2) + cout << " "; + if (c == 3) + cout << " "; + if (c == 4) + cout << " "; + if (c == 5) + cout << " "; + if (c == 6) + cout << " "; + cout << " "; + for (j; j <= 31; j++) + { + cout << j << " "; + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 31) + { + cout << endl; + cout << " "; + } + d2++; + } + } + } + cout << endl; + cout << " September October" << endl; + cout << "Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat" << endl; + i = 1, j = 1, d1 = 1, d2 = 1, m1 = 9, m2 = 10; + c = weekjudge(d1, m1, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + for (i; i <= 30; i++) + { + if (i >= 1 && i < 9) + { + cout << i << " "; + } + else if (i >= 9 && i < 31) + { + cout << i << " "; + } + int c = weekjudge(d1, m1, y); + if (c == 6) + { + if (i >= 1 && i < 10) + { + cout << " "; + } + else if (i >= 10 && i < 31) + { + cout << " "; + } + if (j < 10 && j != 1) + { + cout << " "; + } + else if (j >= 10 && j < 32) + { + cout << " "; + } + if (i == 9 && c == 6) + { + cout << " "; + } + for (j; j <= 31; j++) + { + if (j == 1) + { + int c = weekjudge(d2, m2, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + } + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < 32) + { + cout << j << " "; + } + if (y == 1582 && m2 == 10 && j == 4) + { + cout << "\b"; + j = 14; + d2 = 15; + continue; + } + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 31) + { + j++; + d2++; + cout << endl; + break; + } + if (j == 31) + { + cout << endl; + } + d2++; + } + if (i < 9) + { + cout << " "; + } + else if (i >= 9 && i < 31) + { + cout << " "; + } + } + d1++; + if (i == 30 && d2 != 31) + { + d1 = 30; + int c = weekjudge(d1, m1, y); + if (c == 0) + cout << " "; + if (c == 1) + cout << " "; + if (c == 2) + cout << " "; + if (c == 3) + cout << " "; + if (c == 4) + cout << " "; + if (c == 5) + cout << " "; + if (c == 6) + cout << " "; + cout << " "; + for (j; j <= 31; j++) + { + cout << j << " "; + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 31) + { + cout << endl; + cout << " "; + } + d2++; + } + } + c = weekjudge(d1, m1, y); + if (y==1582 && m2==10 && i == 29) + { + cout << endl; + cout << " "; + } + } + cout << endl; + cout << " November December" << endl; + cout << "Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat" << endl; + i = 1, j = 1, d1 = 1, d2 = 1, m1 = 11, m2 = 12; + c = weekjudge(d1, m1, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + for (i; i <= 30; i++) + { + if (i >= 1 && i < 9) + { + cout << i << " "; + } + else if (i >= 9 && i < 31) + { + cout << i << " "; + } + int c = weekjudge(d1, m1, y); + if (c == 6) + { + if (i >= 1 && i < 10) + { + cout << " "; + } + else if (i >= 10 && i < 31) + { + cout << " "; + } + if (j < 10 && j != 1) + { + cout << " "; + } + else if (j >= 10 && j < 32) + { + cout << " "; + } + if (i == 9 && c == 6) + { + cout << " "; + } + for (j; j <= 31; j++) + { + if (j == 1) + { + int c = weekjudge(d2, m2, y); + if (c == 0) + { + cout << " "; + } + else if (c == 1) + { + cout << " "; + } + else if (c == 2) + { + cout << " "; + } + else if (c == 3) + { + cout << " "; + } + else if (c == 4) + { + cout << " "; + } + else if (c == 5) + { + cout << " "; + } + else if (c == 6) + { + cout << " "; + } + } + if (j >= 1 && j < 9) + { + cout << j << " "; + } + else if (j >= 9 && j < 32) + { + cout << j << " "; + } + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 31) + { + j++; + d2++; + cout << endl; + break; + } + if (j == 31) + { + cout << endl; + } + d2++; + } + if (i < 9) + { + cout << " "; + } + else if (i >= 9 && i < 31) + { + cout << " "; + } + } + d1++; + if (i == 30 && d2 != 31) + { + d1 = 30; + int c = weekjudge(d1, m1, y); + if (c == 0) + cout << " "; + if (c == 1) + cout << " "; + if (c == 2) + cout << " "; + if (c == 3) + cout << " "; + if (c == 4) + cout << " "; + if (c == 5) + cout << " "; + if (c == 6) + cout << " "; + cout << " "; + for (j; j <= 31; j++) + { + cout << j << " "; + int c = weekjudge(d2, m2, y); + if (c == 6 && d2 != 31) + { + cout << endl; + cout << " "; + } + d2++; + } + } + } + cout << endl; + goto start; + } + } + else if (a == "3") + { + goto end1; + } + else + { + cout << "" << endl << endl; + goto start; + } + end1: + return 0; +} \ No newline at end of file diff --git a/stu2024/计科2402 胡深然.cpp b/stu2024/计科2402 胡深然.cpp new file mode 100644 index 0000000..73d14e3 --- /dev/null +++ b/stu2024/计科2402 胡深然.cpp @@ -0,0 +1,454 @@ +#include + + +int run (int y); +void search (void); +int pand(int a,int b,int c); +void input(int *a,int *b,int *c); +void rls(void); +void rld (void); +void choice(void); + +int main () +{ + int xz; + printf("ѡҪĹܣ\n"); + printf("1.ѯijijijΪڼжǷΪ\n"); + printf("2.һ\n"); + printf("룺1 or 2\n"); + scanf("%ld",&xz); + if (xz==1) + search(); + else if (xz==2) + choice(); + else + printf("ؿ"); + +} + +//ղж +void input( int *pa,int *pb,int *pc) +{ + printf("꣺\n"); + scanf("%ld",pa); + printf("£\n"); + scanf("%ld",pb); + printf("գ\n"); + scanf("%ld",pc); +} + + +//((year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400+1)%7 + +int run(int x) +{ + if((x%4)==0&&(x%100)!=0||(x%400)==0) + return 1; + else + return 0; +} + + +//жǷ +int pand(int a,int b,int c) +{ + int i=0; + int j[12]={31,28,31,30,31,30,31,31,30,31,30,31}; + if(a>0&&a<99999) + i=0; + else + i=-1; + if(b>=1&&b<=12) + i=0; + else + i=-1; + if(run(a)) + j[2]=29; + if(j[b-1]>=c&&j[b-1]>=1) + i=0; + else + i=-1; + return i; +} + +//ѯijijijΪڼжǷΪ +void search() +{ + int year,mouth,day; + + input(&year,&mouth,&day); + int a,b,c; + b=mouth; + c=day; + char s[10]; + a=pand(year,mouth,day); + if(a==-1) + printf("ؿ"); + else + { + int i=0,j=year/100,y=year%100; + if(year<1582||year==1582&&mouth<10||year==1582&&mouth==10&&c<3) + { + if(mouth==1||mouth==2) + { + mouth+=12; + y--; + } + i=(y+(y/4)+(j/4)-2*j+(13*(b+1)/5)+c+2)%7; + } + else + { + if(mouth==1||mouth==2) + { + mouth+=12; + y--; + } + i=((j/4)-2*j+y+(y/4)+(13*(b+1)/5)+c-1)% 7; + } + + switch(i) + { + case 0:printf("");break; + case 1:printf("һ");break; + case 2:printf("ڶ");break; + case 3:printf("");break; + case 4:printf("");break; + case 5:printf("");break; + case 6:printf(""); + } + if(run(year)) + printf("\n"); + else + printf("\n겻"); + } + + return ; +} +void choice() +{ + int s; + printf("ѡʽ\n"); + printf("1. or 2.˫ :"); + scanf("%ld",&s); + printf("\n"); + if(s==1) + rld(); + else if(s==2) + rls(); + else + printf("ؿ"); +} + +//һ +void rld() +{ + int year,mouth,day; + input(&year,&mouth,&day); + + //printf("ѡ") + int u=pand(year,mouth,day); + if(u==-1) + printf("ؿ"); + else + { + + int i,j,n=0,leap; + leap=(year%4==0&&year%100!=0)||(year%100==0); + int k=year/100,y=(year%100)-1; + if(year<=1582) + { + n=(y+(y/4)+(k/4)-2*k+(13*14/5)+3)%7; + } + else + { + n=((k/4)-2*k+y+(y/4)+(13*14/5))% 7; + } + + //printf("%d",n); + + for(mouth=1;mouth<=12;mouth++) + { + switch(mouth) + { + case 1: + day=31; + printf("һ\t\t%d\n",year); + break; + case 2: + if(leap) + day=29; + else + day=28; + printf("\t\t%d\n",year); + break; + case 3: + day=31; + printf("\t\t%d\n",year); + break; + case 4: + day=30; + printf("\t\t%d\n",year); + break; + case 5: + day=31; + printf("\t\t%d\n",year); + break; + case 6: + day=30; + printf("\t\t%d\n",year); + break; + case 7: + day=31; + printf("\t\t%d\n",year); + break; + case 8: + day=31; + printf("\t\t%d\n",year); + break; + case 9: + day=30; + printf("\t\t%d\n",year); + break; + case 10: + day=31; + printf("ʮ\t\t%d\n",year); + break; + case 11: + day=30; + printf("ʮһ\t\t%d\n",year); + break; + case 12: + day=31; + printf("ʮ\t\t%d\n",year); + break; + + } + printf("----------------------------------------------------\n"); + printf(" SUN MON TUE WED THD FRI SAT\n"); + + switch(n) + { + case 1: + printf("%5c",'\40'); + break; + case 2: + printf("%10c",'\40'); + break; + case 3: + printf("%15c",'\40'); + break; + case 4: + printf("%20c",'\40'); + break; + case 5: + printf("%25c",'\40'); + break; + case 6: + printf("%30c",'\40'); + break; + } + + for(i=1,j=n;i<=day;i++,j++) + { + printf("%5d",i); + + if(j%7==6) + printf("\n"); + } + + n=(n+day)%7; + printf("\n----------------------------------------------------"); + + printf("\n"); + } +} + +} + + + +void rls() +{ + int year,mouth,day; + input(&year,&mouth,&day); + int u=pand(year,mouth,day); + if(u==-1) + printf("ؿ"); + else + { + int i,j,n1=0,leap; + leap=(year%4==0&&year%100!=0)||(year%100==0); + int day1,day2; + int k=year/100,y=(year%100)-1; + if(year<=1582) + { + n1=(y+(y/4)+(k/4)-2*k+(13*14/5)+3)%7; + } + else + { + n1=((k/4)-2*k+y+(y/4)+(13*14/5))% 7; + } + for(mouth=1;mouth<=12;mouth+=2) + { + switch(mouth) + { + case 1: + day1=31; + printf("һ\t\t%d",year); + if(leap) + day2=29; + else + day2=28; + printf("\t\t\t\t\t\t\t%d\n",year); + break; + case 3: + day1=31; + printf("\t\t%d",year); + day2=30; + printf("\t\t\t\t\t\t\t%d\n",year); + break; + case 5: + day1=31; + printf("\t\t%d",year); + day2=30; + printf("\t\t\t\t\t\t\t%d\n",year); + break; + case 7: + day1=31; + printf("\t\t%d",year); + day2=31; + printf("\t\t\t\t\t\t\t%d\n",year); + break; + case 9: + day1=30; + printf("\t\t%d",year); + day2=31; + printf("\t\t\t\t\tʮ\t\t%d\n",year); + break; + case 11: + day1=30; + printf("ʮһ\t\t%d",year); + day2=31; + printf("\t\t\t\t\tʮ\t\t%d\n",year); + break; + + } + printf("--------------------------------------------------------------------------------------------------------\n"); + printf(" SUN MON TUE WED THD FRI SAT\t\t SUN MON TUE WED THD FRI SAT\n"); + + int n2=(n1+day1)%7; + + switch(n1) + { + case 1: + printf("%5c",'\40'); + break; + case 2: + printf("%10c",'\40'); + break; + case 3: + printf("%15c",'\40'); + break; + case 4: + printf("%20c",'\40'); + break; + case 5: + printf("%25c",'\40'); + break; + case 6: + printf("%30c",'\40'); + break; + } + + int x=1,y=n2; + for(i=1,j=n1;i<=50;i++) + { + if(i<=day1) + printf("%5d",i); + if(i==day1) + { + switch((n1+day1)%7) + { + + case 1: + printf("%30c",'\40'); + break; + case 2: + printf("%25c",'\40'); + break; + case 3: + printf("%20c",'\40'); + break; + case 4: + printf("%15c",'\40'); + break; + case 5: + printf("%10c",'\40'); + break; + case 6: + printf("%5c",'\40'); + break; + } + } + + if(j%7==6||i==day1&&x!=day2) + { + printf("\t\t"); + if(j==6) + { + switch(n2) + { + case 1: + printf("%5c",'\40'); + break; + case 2: + printf("%10c",'\40'); + break; + case 3: + printf("%15c",'\40'); + break; + case 4: + printf("%20c",'\40'); + break; + case 5: + printf("%25c",'\40'); + break; + case 6: + printf("%30c",'\40'); + break; + } + } + + while(x<=day2) + { + printf("%5d",x); + if(y%7==6) + { + x+=1; + y+=1; + break; + } + x++; + y++; + } + printf("\n"); + } + + j++; + + } + + int temp=n1; + n1=(n2+day)%7; + n2=(temp+day)%7; + printf("\n--------------------------------------------------------------------------------------------------------\n"); + } + + } +} + + + + + + diff --git a/stu2024/计科2402刘相宁.cpp b/stu2024/计科2402刘相宁.cpp new file mode 100644 index 0000000..cba7f6c --- /dev/null +++ b/stu2024/计科2402刘相宁.cpp @@ -0,0 +1,326 @@ +#include +#include + + +int main(){ + + int a; + + printf("1:鿴ΪڼǷΪ\n"); + printf("2:\n"); + printf("3:˫\n"); + printf("0:0˳\n"); + printf("ѯ\n"); + scanf("%d",&a); + switch(a){ + case(0):break; + + + case(1): + + + while(1){ + //ڼ㷽ԪԪ11ָ%7 + int year,month,day; + printf("(ʽ0000)\n"); + scanf("%d",&year);// + + if(year==0) + break; + + + if(year==1582&&month==10&&day>4&&day<15){ + printf("\n\n\n"); + continue;} + + + + + //ж + int sumyear1=0;//ʾӹԪԪ꿪ʼ ,ʾ + if(year>1582){ + for(int i=1;i<=year-1;i++){ + if((i%4==0&&i%100!=0)||i%400==0)//ж귽 + sumyear1++; + } + } + else{ + for(int i=1;i<=year-1;i++){ + if(i%4==0){ + sumyear1++; + } + //ж귽 + } + sumyear1+=5;//1582깫ԪԪԼ + } + int sumday;//ͳ + sumday=(year-1)*365+sumyear1;//ͳȥ + + // жϹ + int feb; + if(year>1582){ + if((year%4==0&&year%100!=0)||year%400==0){ + printf("%d\n\n",year); + feb=29;} + else{ + printf("%dƽ\n\n",year); + feb=28;} + } + else{ + if(year%4==0){ + + feb=29; + printf("%d\n\n",year);} + else{ + printf("%dƽ\n\n",year); + feb=28;} + } + int a[13]={0,31,feb,31,30,31,30,31,31,30,31,30,31}; + printf("(ʽ00)\n"); + scanf("%d",&month); + if(month==0) + break;//· + + //ͳƹԪԪȥӱһ + for(int i=1;i<=month-1;i++) + sumday+=a[i];//ͳ + if(year==1582&&(month==11||month==12)) + sumday+=11; + + printf("(ʽ00)\n\n"); + scanf("%d",&day);// + if(day==0) + break; + + if(year==1582&&month==10&&day>4&&day<15){ + printf("\n"); + continue; + } + //ӹԪԪ꿪ʼ + int week; + if(year==1582&&month==10&&day>=15){ + week=(sumday+day-10)%7; + } + else week=(sumday+day)%7; + if(week!=0){ + printf("%d%d%d%d\n\n",year,month,day,week); + } + else{ + printf("%d%d%d\n\n",year,month,day); + } + } + break; + + + + case(2): + while(1){/////////////ظ + //ڼ㷽ԪԪ11ָ%7 + int year,month; + printf("(ʽ0000)\n"); + scanf("%d",&year);// + + if(year==0) + break; + + + //ж + int sumyear1=0;//ʾӹԪԪ꿪ʼ ,ʾ + if(year>1582){ + for(int i=1;i<=year-1;i++){ + if((i%4==0&&i%100!=0)||i%400==0)//ж귽 + sumyear1++; + } + } + else{ + for(int i=1;i<=year-1;i++){ + if(i%4==0){ + sumyear1++; + } + //ж귽 + } + sumyear1+=5;//1582깫ԪԪԼ + } + int sumday;//ͳ + sumday=(year-1)*365+sumyear1;//ͳȥ + + // жϹ + int feb; + if(year>1582){ + if((year%4==0&&year%100!=0)||year%400==0){ + feb=29;} + else{ + feb=28;} + } + else{ + if(year%4==0){ + + feb=29;} + else{ + feb=28;} + } + int a[13]={0,31,feb,31,30,31,30,31,31,30,31,30,31}; + for(month=1;month<=12;month++){ + //ͳƹԪԪȥӱһ + for(int i=1;i<=month-1;i++) + sumday+=a[i];//ͳ + if(year==1582&&(month==11||month==12)) + sumday+=11; + + int day=1,week; + week=(sumday+day)%7; + + printf("\n------------------ %d %d ---------------------\n\n",year,month); + printf(" һ \n\n"); + + ///1 + for(int j=1;j<=week;j++){ + printf(" "); + } + // ڼ1>=7 + if(year==1582&&month==10){ + for(int j=1;j<=a[month];j++){ + printf("%d ", j); + if((week+j)>=7){ + printf("\n\n"); + week-=7; + } + if(j==4){//ж1582 + j+=10; + week-=10; + } + } + } + else{ + for(int j=1;j<=a[month];j++){ + printf("%d ", j); + if((week+j)>=7){ + printf("\n\n"); + week-=7; + } + } + } + } + } + + + case(3): + while(1){/////////////ظ ˫ + //ڼ㷽ԪԪ11ָ%7 + int year,month; + printf("(ʽ0000)\n"); + scanf("%d",&year);// + + if(year==0) + break; + + + //ж + int sumyear1=0;//ʾӹԪԪ꿪ʼ ,ʾ + if(year>1582){ + for(int i=1;i<=year-1;i++){ + if((i%4==0&&i%100!=0)||i%400==0)//ж귽 + sumyear1++; + } + } + else{ + for(int i=1;i<=year-1;i++){ + if(i%4==0){ + sumyear1++; + } + //ж귽 + } + sumyear1+=5;//1582깫ԪԪԼ + } + int sumday;//ͳ + sumday=(year-1)*365+sumyear1;//ͳȥ + + // жϹ + int feb; + if(year>1582){ + if((year%4==0&&year%100!=0)||year%400==0){ + feb=29;} + else{ + feb=28;} + } + else{ + if(year%4==0){ + + feb=29;} + else{ + feb=28;} + } + int a[13]={0,31,feb,31,30,31,30,31,31,30,31,30,31}; + for(month=1;month<=12;month++){ + //ͳƹԪԪȥӱһ + for(int i=1;i<=month-1;i++) + sumday+=a[i];//ͳ + if(year==1582&&(month==11||month==12)) + sumday+=11; + + int day=1,week; + week=(sumday+day)%7; + + printf("\n--------------------------------------------\n\n"); + printf(" һ һ \n\n"); + for(month=1;month<=12;month+=2){ + + ///1 + for(int j=1;j<=week;j++){ + printf(" "); + } + // ڼ1>=7 + + for(int j=1;j<=a[month+2];j++){ + printf("%d ", j); + if((week+j)>=7){ + printf("\n\n"); + week-=7; + } + } + } + for(month=2;month<=12;month+=2){ + for(int j=1;j<=week;j++){ + printf(" "); + } + // ڼ1>=7 + if(year==1582&&month==10){ + for(int j=1;j<=a[month];j++){ + printf("%d ", j); + if((week+j)>=7){ + printf("\n\n"); + week-=7; + } + if(j==4){//ж1582 + j+=10; + week-=10; + } + } + } + else{ + for(int j=1;j<=a[month];j++){ + printf("%d ", j); + if((week+j)>=7){ + printf("\n\n"); + week-=7; + } + } + } + + } + } + + +} + +} + + +return 0; +} + + + + + + diff --git a/stu2024/计科2402吕伟焘.cpp b/stu2024/计科2402吕伟焘.cpp new file mode 100644 index 0000000..1774f65 --- /dev/null +++ b/stu2024/计科2402吕伟焘.cpp @@ -0,0 +1,254 @@ +#include +#include +#include + +void arr(long long int year,int month,int day)//жڼ +{ + int w; + printf("\n\n\n\n\n\n\n\n\n\n\n\n\n"); + printf(" **************************************\n"); + printf(" * *\n"); + printf(" * *\n"); + printf(" * ӭʹ *\n"); + printf(" * *\n"); + printf(" * *\n"); + printf(" **************************************\n"); + printf(" *ڣ"); + while(scanf("%lld %d %d",&year,&month,&day)!=EOF) + { + int c=year/100; + int y=year%100; + if(month<0||month>12||day>31) + { + printf(" *ڣ"); + } + else + { + if(year<1582||(year==1582&&month<10)||(year==1582&&month==10&&day<=4)) + { + + if(month==1||month==2) + { + y--; + month+=12; + } + w=(y+y/4+c/4-2*c+(13*(month+1))/5+day+2)%7; + } + else + { + if(month==1||month==2) + { + y--; + month+=12; + } + w=(y+y/4+c/4-2*c+(13*(month+1))/5+day-1)%7; + + } + if(year==1582&&month>10) + { + w -=3; + } + + switch(w) + { + case 1: + printf("һ\n");break; + case 2: + printf("ڶ\n");break; + case 3: + printf("\n");break; + case 4: + printf("\n");break; + case 5: + printf("\n");break; + case 6: + printf("\n");break; + case 0: + printf("\n"); + } + + } + } + + return ; +} +void add(long long int year)//ж +{ + printf("\n\n\n\n\n\n\n\n\n\n\n\n\n"); + printf(" **************************************\n"); + printf(" * *\n"); + printf(" * *\n"); + printf(" * ӭʹ *\n"); + printf(" * *\n"); + printf(" * *\n"); + printf(" **************************************\n"); + printf(" *ݣ"); + scanf("%lld",&year); + if((year%4==0&&year%100!=0)||(year%100==0)) + printf(" "); + else + printf(" ƽ"); + + return ; +} +void abb(long long int year,int month,int day)// +{ + + int i,j,n,leap; + printf("\n\n\n\n\n\n\n\n\n\n\n\n\n"); + printf(" **************************************\n"); + printf(" * *\n"); + printf(" * *\n"); + printf(" * ӭʹ *\n"); + printf(" * *\n"); + printf(" * *\n"); + printf(" **************************************\n"); + printf(" *ݣ"); + scanf("%lld",&year); + printf("\n\n"); + + leap=(year%4==0&&year%100!=0)||(year%100==0); + + n=((year-1)*365+ (year-1)/4-(year-1)/100+(year-1)/400+1) % 7; + + for(month=1;month<=12;month++) + { + switch(month) + { + case 1: + day=31; + printf("һ(%d)\t\t%lld\n",month,year); + break; + case 2: + if(leap) + day=29; + else + day=28; + printf("(%d)\t\t%lld\n",month,year); + break; + case 3: + day=31; + printf("(%d)\t\t%lld\n",month,year); + break; + case 4: + day=30; + printf("(%d)\t\t%lld\n",month,year); + break; + case 5: + day=31; + printf("(%d)\t\t%lld\n",month,year); + break; + case 6: + day=30; + printf("(%d)\t\t%lld\n",month,year); + break; + case 7: + day=31; + printf("(%d)\t\t%lld\n",month,year); + break; + case 8: + day=31; + printf("(%d)\t\t%lld\n",month,year); + break; + case 9: + day=30; + printf("(%d)\t\t%lld\n",month,year); + break; + case 10: + day=31; + printf("ʮ(%d)\t\t%lld\n",month,year); + break; + case 11: + day=30; + printf("ʮһ(%d)\t\t%lld\n",month,year); + break; + case 12: + day=31; + printf("ʮ(%d)\t\t%lld\n",month,year); + break; + + } + printf("----------------------------------------------------\n"); + printf(" SUN MON TUE WED THD FRI SAT\n"); + + switch(n) + { + case 1: + printf("%5c",'\40'); + break; + case 2: + printf("%10c",'\40'); + break; + case 3: + printf("%15c",'\40'); + break; + case 4: + printf("%20c",'\40'); + break; + case 5: + printf("%25c",'\40'); + break; + case 6: + printf("%30c",'\40'); + break; + } + + for(i=1,j=n;i<=day;i++,j++) + { + printf("%5d",i); + + if(j%7==6) + printf("\n"); + } + + n=(n+day)%7; + printf("\n----------------------------------------------------\n"); + } + + + return ; +} +void mean_main(long long int year,int month,int day)//˵ +{ + int a; + while(1) + { + + printf("\n\n\n\n\n\n\n\n\n\n\n\n\n"); + printf(" **************************************\n"); + printf(" * ӭʹ *\n"); + printf(" * 1. *\n"); + printf(" * 2. *\n"); + printf(" * 3.ѯӦ *\n"); + printf(" * 4.˳ϵͳ *\n"); + printf(" **************************************\n"); + printf(" *루1~4:"); + do + { + scanf("%d",&a); + if(a>0&&a<5) + break; + else + printf(" *룺"); + + }while(1); + system("cls"); + switch(a) + { + case 1:add(year);break; + case 2:abb(year,month,day);break; + case 3:arr(year,month,day);break; + case 4:break; + } + } + + return ; +} +int main() +{ + long long int year; + int month,day; + mean_main(year,month,day); + +} + diff --git a/stu2024/计科2402沈意佳.cpp b/stu2024/计科2402沈意佳.cpp new file mode 100644 index 0000000..213b318 --- /dev/null +++ b/stu2024/计科2402沈意佳.cpp @@ -0,0 +1,183 @@ +#include +#include + + +int isLeapYear(int year) { + if ((year % 4 == 0 && year % 100!= 0) || (year % 400 == 0)) { + return 1; + } + return 0; +} +int getDaysInMonth(int year,int month){ + scanf("%d%d",&year,&month); + if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) + printf("31"); + else if(month==4||month==6||month==9||month==11) + printf("30"); + else{ + if((year % 4 == 0 && year % 100!= 0) || (year % 400 == 0)) + printf("29"); + else + printf("28"); + } + return 0; +} + +int getDayOfWeek(int year, int month, int day) { + if (month < 3) { + month += 12; + year--; + } + int c = year / 100; + int y = year % 100; + int week = (day + 2 * month + 3 * (month + 1) / 5 + y + y / 4 + c / 4 - 2 * c + 7) % 7; + return week; +} + +/**/ +void x(int year, int month) { + printf("%d%d\n", year, month); + printf(" һ \n"); + + int dayOfWeek = getDayOfWeek(year, month, 1); + for (int i = 0; i < dayOfWeek; i++) { + printf(" "); + } + int daysInMonth; + int getDaysInMonth; + for (int i = 1; i <= daysInMonth; i++) { + printf("%2d ", i); + if ((i + dayOfWeek) % 7 == 0) { + printf("\n"); + } + } + if ((daysInMonth + dayOfWeek) % 7!= 0) { + printf("\n"); + } +} +void z(int year, int month) { + printf(" %d%d%d%d\n", year, month, year, month + 1); + printf(" һ һ \n"); + + int dayOfWeek1 = getDayOfWeek(year, month, 1); + int dayOfWeek2 = getDayOfWeek(year, month + 1, 1); + + for (int i = 0; i < dayOfWeek1; i++) { + printf(" "); + } + + int daysInMonth1 ; + int daysInMonth2 ; + + int i1 = 1, i2 = 1; + while (i1 <= daysInMonth1 || i2 <= daysInMonth2) { + if (i1 <= daysInMonth1) { + printf("%2d ", i1); + i1++; + } else { + printf(" "); + } + + if ((i1 + dayOfWeek1 - 1) % 7 == 0 && i1 <= daysInMonth1) { + printf(" "); + } + + if (i2 <= daysInMonth2) { + printf("%2d ", i2); + i2++; + } else { + printf(" "); + } + + if ((i2 + dayOfWeek2 - 1) % 7 == 0 && i2 <= daysInMonth2) { + printf("\n"); + } + } + if ((daysInMonth1 + dayOfWeek1) % 7!= 0 || (daysInMonth2 + dayOfWeek2) % 7!= 0) { + printf("\n"); + } +} +void showMenu() { + printf("˵\n"); + printf("1. ѯijijijյܼǷΪ\n"); + printf("2. ݣһĵ\n"); + printf("3. ݣһ˫ʾ£\n"); + printf("4."); +} + int main() { + int choice; + int year, month, day; + int m; + do { + showMenu(); + scanf("%d",&choice); + + switch (choice) { + case 1: + printf("ݣ"); + scanf("%d",&year); + printf("·ݣ"); + scanf("%d",&month);; + printf("ڣ"); + scanf("%d",&day); + + if (year < 1583 && year == 1582 && month == 10 && day >= 5 && day <= 14) { + printf("1582105 - 14ղڣ롣\n"); + continue; + } + + printf("%d%d%d", year, month, day); + switch (getDayOfWeek(year, month, day)) { + case 0: + printf("\n"); + break; + case 1: + printf("һ\n"); + break; + case 2: + printf("\n"); + break; + case 3: + printf("\n"); + break; + case 4: + printf("\n"); + break; + case 5: + printf("\n"); + break; + case 6: + printf("\n"); + break; + } + + if (is LeapYear){ + printf("%d\n", year); + } else { + printf("%d겻\n", year); + } + break; + case 2: + printf("ݣ"); + scanf("%d",&year); + for (month = 1; month <= 12; month++) { + x(year, month); + printf("\n"); + } + break; + case 3: + printf("ݣ"); + scanf("%d",&year);; + for (month = 1; month <= 11; month += 2) { + z(year, month); + printf("\n"); + } + break; + default: + printf("Чѡ롣\n"); + } + } while (choice!= 0); + + return 0; +} + diff --git a/stu2024/计科2402王娅晗.cpp b/stu2024/计科2402王娅晗.cpp new file mode 100644 index 0000000..134c709 --- /dev/null +++ b/stu2024/计科2402王娅晗.cpp @@ -0,0 +1,249 @@ +#include +void fun(void); +int year; +int shiji; +int yue; +int ri; +int w;// +int y; //ݺλ +void getday(int first_day[],int y); +void shuchurili(int days[],int first_day[]); + +int main() + {{ + int a; + printf("ѯijijijյܼǷΪ 1\n"); + printf("ݣһҪܹ˫ 2\n"); + scanf("%d",&a); + if(a==1) +{ + scanf("%d-%d-%d",&year,&yue,&ri); + if((year<=0||yue<=0||ri<=0)||(year==1582&&yue==10&&(ri==5||ri==6||ri==7||ri==8||ri==9||ri==10||ri==11||ri==12||ri==13||ri==14)) + {{ + printf("룺"); + scanf("%d-%d-%d",&year,&yue,&ri); + } }else { + if(yue<3) + { + year--; + yue+=12; + } + shiji=(year/100); + y=year%100; + w=shiji/4-2*shiji+y+y/4+13*(yue+1)/5+ri-1; + if(w%7==0) + printf("7"); + else + printf("%d ",w%7); + if((year%4==0&&year%100!=0)||(year%400==0)) + printf(""); + else + printf(""); + } +}} + + +//ڶ + + + + + + if(a==2) + { + //˫ѡ + printf("ѡҪĸʽ\n"); + printf("밴1\n"); + printf("˫밴2\n"); + int b; + scanf("%d",&b); + if(b==1) + { + int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; + int first_day[12]={0}; + int year=0; + int i=0; + int a=1; + while(a) + { + printf("ݣ"); + scanf("%d",&year); + // + if(year<=0) + { + printf("룺"); + scanf("%d",&year); + } + --a; + } + //ȡÿ + getday(first_day,year); + if((year%4==0&&year%100!=0)||(year%400==0)) + days[1]=29; + // + shuchurili(days,first_day); + return 0; +}else + + +//˫ + + + +{ + int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; + int first_day[12]={0}; + int year=0; + int i=0; + int a=1; + while(a) + { + printf("ݣ"); + scanf("%d",&year); + // + if(year<=0) + { + printf("룺"); + scanf("%d",&year); + } + --a; + } + //ȡÿ + getday(first_day,year); + if((year%4==0&&year%100!=0)||(year%400==0)) + days[1]=29; + // + shuchurili(days,first_day); + return 0; + + + +} +} +return 0; +} + + + + + +void getday(int first_day[],int y) +{ + int m=0; + int d=1; + int w=0; + for(m=3;m<=12;m++) + { + w=(d+1+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7; + first_day[m-1]=w; + } + y-=1; + for (m=13;m<=14;m++) + { + w = (d+1+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7; + first_day[m-13] = w; + } +} +void shuchurili(int days[],int first_day[]) +{ + int dyt=0; + int d=0,i=0,j=0; + for(i=0;i<12;i++) + { + dyt=first_day[i]; + printf(" %2d \n", i+1); + printf(" һ \n"); + //1ǰĿո +//ĺ + for(j=0;j +//жĺ + int isleapyear(int year) + { + return ((year%4==0&&year%100!=0)||(year%400==0)); + } + + //ÿĺ + int month(int year,int yue) + { + int run[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + if(yue==2&&isleapyear(year)) + { + return 29; + } + return run[yue]; + } + + //ڼչʽ + int week(int year,int yue,int ri) + { + if(yue<3) + { + year--; + yue+=12; + } + shiji=(year/100); + y=year%100; + w=shiji/4-2*shiji+y+y/4+13*(yue+1)/5+ri-1; + return (w%7+7)%7; + } + + // + void rili(int year) + { + char *week[]={"һ","","","","","",""}; + scanf("&d-%d-%d",&year,&yue,&ri); + for(yue=1;yue<=12;yue++) + { + int i; + printf("%d ",yue); + for(i=0;i<7;i++) + printf("%s",week[i]); + printf("\n"); + int w=week(year,yue,1);//wΪÿµһڼ + int jx=month(year,yue); + char a[w]={"0"}; + char b[][7];//ڵ + if((year%4==0&&year%100!=0)||(year%400==0)) + { + for(int n=0;n<7;n++) + { + for(int m=1;m +#include +int year,month,day; +int run[12]={31,29,31,30,31,30,31,31,30,31,30,31}; +int ping[12]={31,28,31,30,31,30,31,31,30,31,30,31}; +char weekday[7][10]={"һ","ڶ","","","","",""}; +char yuefen[12][20]={"һ","","","","","","","","","ʮ","ʮһ","ʮ"}; +int leap(int year) +{ + if(year%4==0&&year%100!=0||year%400==0) + { + return 1; + } + else + { + return 0; + } +} +int nian(int year,int month,int day,int run[],int ping[]) +{ + int i,sum=0; + for(i=1900;i + +// жǷΪ (1582ǰ죩 +int isLeapYear(int year) { + if (year >= 1582) { + if ((year%4 ==0 && year%100!=0) || year%400==0) { + return 1; + } + return 0; + } else { + if (year % 4 == 0) { + return 1; + } + return 0; + } +} + +// ǷΪ +int isnumber(char input[]) { + int i = 0; + while (input[i]!= '\0') { + if (input[i] < '0' || input[i] > '9') { + return 0; + } + i++; + } + return 1; +} + +// ǷЧ +int Dateisture(int year, int month, int day) { + if (year == 1582 && month == 10 && (day > 4 && day <= 14)) { + return 0; + } + + int daysInMonth[] = {0, 31, 28, 31, 32, 30, 31, 30, 31, 30, 31, 30, 31}; + if (isLeapYear(year)) { + daysInMonth[2] = 29; + } + + if(year>=1 && month>=1 && month<=12 && day>=1 && day<=daysInMonth[month]){ + return 1; + } + return 0; +} + +// ڼ1582ǰ죩 +int dayOfWeek(int year, int month, int day) { + if (year >= 1582) { + if (month < 3) { + year--; + month += 12; + } + int c = year / 100; + int y = year % 100; + int week = (c / 4 - 2 * c + y + y / 4 + 13 * (month + 1) / 5 + day - 1) % 7; + if (week < 0) { + week += 7; + } + return week; + } else { + int a = (14 - month) / 12; + int y = year - a; + int m = month + 12 * a - 2; + int week = (day + y + y / 4 - y / 100 + y / 400 + (31 * m) / 12) % 7; + return week; + } +} + +// У +void Single(int year) { + int daysInMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (isLeapYear(year)) { + daysInMonth[2] = 29; + } + printf("%d():\n", year); + int dayOfWeekJan1 = dayOfWeek(year, 1, 1); + for (int month = 1; month <= 12; month++) { + printf("Mon Tue Wed Thu Fri Sat Sun\n"); + for (int day = 1; day <= daysInMonth[month]; day++) { + printf("%3d ", day); + if ((dayOfWeekJan1 + day) % 7 == 0 && day!= daysInMonth[month]) { + printf("\n"); + } + }printf("\n"); + } + printf("\n"); +} + +// ˫У +void Double(int year) { + int daysInMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (isLeapYear(year)) { + daysInMonth[2] = 29; + } + + printf("%d(˫):\n", year); + int dayOfWeekJan1 = dayOfWeek(year, 1, 1); + for (int month = 1; month <= 12; month++) { + printf("Mon Tue Wed Thu Fri Sat Sun \t Mon Tue Wed Thu Fri Sat Sun"); + for (int day = 1; day <= daysInMonth[month]; day++) { + printf("%3d ", day); + if ((dayOfWeekJan1 + day) % 7 == 0 && day!= daysInMonth[month]) { + printf("\n"); + } + }printf("\n"); + } + printf("\n"); +} + +int main() { + char choice[10]; + int zh; + do{ + printf("1. ѯijijijڼǷΪ\n"); + printf("2. ѯij\n"); + printf("3. ϸ\n"); + printf("ѡ: "); + scanf("%9s",choice); + if(!isnumber(choice)){ + printf("\n"); + continue; + } + zh=choice[0]-'0'; + switch(zh){ + case 1: char years[10], months[10], days[10]; + int year, month, day; + while (1) { + printf(": "); + scanf("%s", years); + if (!isnumber(years)) { + printf("¿ʼ\n"); + continue; + } + year = atoi(years); + printf("·: "); + scanf("%s", months); + if (!isnumber(months)) { + printf("¿ʼ\n"); + continue; + } + month = atoi(months); + + printf(": "); + scanf("%s", days); + if (!isnumber(days)) { + printf("¿ʼ\n"); + continue; + } + day = atoi(days); + + if (!Dateisture(year, month, day)) { + printf("\n"); + continue; + } + + int weekDay = dayOfWeek(year, month, day); + char weekDayNames[][10] = {"һ", "ܶ", "", "", "", "", ""}; + printf("%d-%02d-%02d%s\n", year, month, day, weekDayNames[weekDay]); + if (isLeapYear(year)) { + printf("%d\n", year); + } else { + printf("%d겻\n", year); + } + break; + } + case 2: + char yearss[10]; + while (1) { + printf(": "); + scanf("%s", yearss); + if (!isnumber(yearss)) { + printf("ȷ\n"); + continue; + } + year = atoi(yearss); + Single(year); + Double(year); + break; + } + case 3:printf("");break; + default:printf("ѡȷѡ\n"); + continue; + } + }while(zh!=3); +} diff --git a/stu2024/软件2401范慈惠.cpp b/stu2024/软件2401范慈惠.cpp new file mode 100644 index 0000000..46c7879 --- /dev/null +++ b/stu2024/软件2401范慈惠.cpp @@ -0,0 +1,195 @@ +#include +#include +#include + void Menu1() + { + printf("һʾҪеIJ\n"); + printf("1.ҿһ()\n"); + printf("2.ҿһ(˫)\n"); + printf("3.ҿܼ\n"); + printf("4.ҿһDz\n"); + }//˵ +int main() { + int menu, year; + + Menu1(); // ʾ˵ + scanf("%d", &menu); + + if (menu == 1) { + printf("ҿһ()\n"); + printf("ݣ"); + scanf("%d", &year); + + // 뻺еĻз + while (getchar() != '\n'); + + if (year <= 0) { + printf("\n"); + return 1; // ʹ÷ֵʾ + } + } + +int runnian(int n)//¼· +{ + switch(n) + { + case 1:return 31; + case 2:return 29; + case 3:return 31; + case 4:return 30; + case 5:return 31; + case 6:return 30; + case 7:return 31; + case 8:return 31; + case 9:return 30; + case 10:return 31; } +} +int pingnian(int year,int month)//¼ƽ· +{ + if (year==1582&&month==10) + { + return 21;//158210ֻ21 + } + switch(month) + { + case 1:return 31; + case 2:return 28; + case 3:return 31; + case 4:return 30; + case 5:return 31; + case 6:return 30; + case 7:return 31; + case 8:return 31; + case 9:return 30; + case 10:return 31; + case 11:return 30; + case 12:return 31; + } +} +void run(int week)// +{ + int n=0;//¼д + int w=week; + int i,j,k; + for(i=1;i<=12;i++) + { + printf("%d\n",i); + printf(" һ \n") ; + for(k=0;k0&&week<8);//ѭõijijijյܼ + } +if (menu == 4) { + printf("4.ҿһDz\n"); + + { + int year,month,day; + printf("һݣжϸǷΪ"); + if((year%4==0&&year%100!=0)||(year%400==0))//ж껹ƽ + {printf("");} + else + {printf("");} + } + return 0; +} diff --git a/stu2024/软件2401邱毅杰.cpp b/stu2024/软件2401邱毅杰.cpp new file mode 100644 index 0000000..9a88fad --- /dev/null +++ b/stu2024/软件2401邱毅杰.cpp @@ -0,0 +1,147 @@ +#include +#include +int runYear(int n); //дʹ +int RunYear(int year); +void printMonth(int year, int month); +int dayOfWeek(int year, int month, int day); +void printMonth(int year, int month) +{ + int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + int startDay = dayOfWeek(year, month, 1); + int days = daysInMonth[month - 1]; + if (month == 2 && RunYear(year)) + { + days = 29; + } + else if (year == 1582 && month == 10) + { + days = 21; + } + + printf("\n%d%d\n", year, month); + printf(" һ \n"); + + // ӡոֱһ + for (int i = 0; i < startDay; i++) + { + printf(" "); + } + + // ӡ + for (int day = 1; day <= days; day++) + { + printf("%2d ", day); + if ((day + startDay) % 7 == 0) + { + printf("\n"); + } + } + printf("\n"); +} + +int dayOfWeek(int year, int month, int day) +{ + if (month < 3) + { + month += 12; + year -= 1; + } + int k = year % 100; + int j = year / 100; + int h = day + 13 * (month + 1) / 5 + k + k / 4 + j / 4 + 5 * j; //zellerʽ + h = h % 7; + return 0; +} +int RunYear(int year) +{ + return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); +} +int runYear(int n) +{ + printf("\n"); + scanf("%d",&n); + if(n%4==0&&n%100!=0||n%400==0) + { + printf("\n"); + } + else + { + printf("\n"); + } +} + +int main() +{ + int choice,n,year,month,day; + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ\n"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n"); + printf("ѡ="); + scanf("%d",&choice); + do + { + switch(choice) + { + case 1: + { + int year; + printf("ݣ"); + scanf("%d", &year); + + // ӡȫ + for (int month = 1; month <= 12; month++) + { + printMonth(year, month); + } + return 0; + } + case 2: + { + printf("ڣ գ\n"); + scanf("%d %d %d",&year,&month,&day); + int runYear(year); + if(0) + { + if (month < 3) //ƽ + { + month += 12; + year -= 1; + } + int c = year % 100; + int y = year / 100; + int h = day + 13 * (month + 1) / 5 + c + c / 4 + y / 4 + 5 * y; //zellerʽ + h = h % 7; + printf("%d",h); + } + else + { + if (month < 3) // + { + month += 12; + year -= 1; + } + int c = year % 100; + int y = year / 100; + int h = day-1 + 13 * (month + 1) / 5 + c + c / 4 + y / 4 + 5 * y; //zellerʽ + h = h % 7; + printf("%d",h); + } + return 0; + } + case 3: + { + runYear(n); + } + case 4: + return 0; + default: + { + printf("ѡ\n"); + printf("ѡ="); + scanf("%d",&choice); + } + } + } while(choice); + return 0; +} diff --git a/stu2024/软件2401陈思宇(1).cpp b/stu2024/软件2401陈思宇(1).cpp new file mode 100644 index 0000000..7df6584 --- /dev/null +++ b/stu2024/软件2401陈思宇(1).cpp @@ -0,0 +1,384 @@ +#include +// +//1.ж꺯 +//2.Ʋѯijijڼ +//3.˫У +//4.˵ѡҪо Ҳ˵ÿ˵Ҫһɹ ÿҪһĺ +//5.1528ʮ,ݲ֤Ϊ̻ʾ1582104պʹøӢ175293պŽʹø + +//1.жϺ˼·ж +int isLeapyear(int year) +{ + return(year%400==0)||(year%4==0&&year%100!=0);//꣬Ϊ +} +int monthsday(int year,int month) +{ + int monthsday[]={31,28,31,30,31,30,31,31,30,31,30,31}; + if (month==2&&isLeapyear(year))//꣬жʮ + { + return 29; + } + return monthsday[month-1]; +} +int getFirstDayOfYear(int year)//ĵһܼ +{ + int d=(year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400; + if (year>1582) + { + if (year==1583) + { + d-=10; + } + } + return d%7; +} +int getDaysInMonth(int year,int month) +{ + int daysInMonth[]={31,28,31,30,31,30,31,31,30,31,30,31}; + if(month==2&&isLeapyear(year)) + { + return 29;//29 + } + if (year == 1582 && month == 10) { + return 21; // 1582ʮֻ21 + } + return daysInMonth[month-1];//ضӦ·ݵ +} +//ڼ0ʾ1-6ʾһ +int getDayOfWeek(int year, int month, int day) + { + int t[]={0,3,2,5,0,3,5,1,4,6,2,4};//ͬڲͬеƫ + if (month<3) + { + year--; + } + return(year+year/4-year/100+year/400+t[month-1]+day)%7; +} +//2.ѯܼ +int week(int year,int month,int day)//̩չʽ +{ + if(month<3) + { + month+=12; + year--; + } + if(year<1583) + { + int h=(day+1+2*month+3*(month+1)/5+year+year/4+5)%7; + return h; //hʾijʱڼ + } + else{ + int h=(day+2*month+3*(month+1)/5+year+year/4-year/100+year/400)%7;//չʽw=(d + 1+ 2*m+3*(m+1)/5+y+y/4-y/100+y/400())% + return h+1;//h+1Ϊ1582Ժ󣬲չʽһ + } +} +//3. +int runnian(int n)//¼· +{ + switch(n) + { + case 1:return 31; + case 2:return 29; + case 3:return 31; + case 4:return 30; + case 5:return 31; + case 6:return 30; + case 7:return 31; + case 8:return 31; + case 9:return 30; + case 10:return 31; + case 11:return 30; + case 12:return 31; + } +} +int pingnian(int year,int month)//¼ƽ· +{ + if (year==1582&&month==10) + { + return 21;//158210ֻ21 + } + switch(month) + { + case 1:return 31; + case 2:return 28; + case 3:return 31; + case 4:return 30; + case 5:return 31; + case 6:return 30; + case 7:return 31; + case 8:return 31; + case 9:return 30; + case 10:return 31; + case 11:return 30; + case 12:return 31; + } +} +void run(int week)// +{ + int n=0;//¼д + int w=week; + for(int i=1;i<=12;i++) + { + printf("%d\n",i); + printf(" һ \n") ; + for(int k=0;k12||day<1||day>getDaysInMonth(year,month)) + { + printf("룺\n"); + continue; + } + else + { + printf("%d%d%d%s\n",year,month,day,week[weekday]); + } + } + else if (menu == 3) + { + printf("뿴һأ"); + if(scanf("%d", &year) != 1) + { + while(getchar() != '\n'); + printf("룺\n"); + continue; + } + if(year<1) + { + printf("룺\n"); + continue; + } + else + { + printf("%d%sŶ\n",year,isLeapyear(year)?"":""); + } + } + else if(menu==4) + { + printf("~\n"); + return 0;//˳ + } + else + { + printf("ĸʽԣ룺\n"); + continue; + } + } + return 0; +} diff --git a/stu2024/软件2402吕亦杰.c b/stu2024/软件2402吕亦杰.c new file mode 100644 index 0000000..cb77ba2 --- /dev/null +++ b/stu2024/软件2402吕亦杰.c @@ -0,0 +1,699 @@ +#include +#include + +#define ll long long +#define BUF 256//定义最大输入长度 + +//-----------------Press to continue函数-------------------------- +int Press_to_continue() +{ + printf("\n[按下任意健继续......]"); + getch();//---------------等待按下按键 + printf("\033c"); + printf("\033[2J"); + printf("\033[0m");//------------清屏函数 + return 0; +} +//----------------------------------------------------------------- + + + +//------将字符转换为数字的函数(写这个是因为直接(int)转换好像会出问题) +int number(char n)//选择穷举!!! +{ + if(n=='0') + return 0; + else if(n=='1') + return 1; + else if(n=='2') + return 2; + else if(n=='3') + return 3; + else if(n=='4') + return 4; + else if(n=='5') + return 5; + else if(n=='6') + return 6; + else if(n=='7') + return 7; + else if(n=='8') + return 8; + else if(n=='9') + return 9; +} +//------------------------------------------------------------------ + + + +//------------------------输入判断函数-------------------------------- +int input() +{ + int flag=0; + int i=0; + char c[BUF]; + ll int num=0; + do//------------判断输入是否合法(仅含数字为合法) + { + flag=0; + scanf("%s",c); + while(c[i]!='\0') + { + if(c[i]!='1' && c[i]!='2' && c[i]!='3' && c[i]!='4' && c[i]!='5' && c[i]!='6' && c[i]!='7' && c[i]!='8' && c[i]!='9' && c[i]!='0') + { + flag=1; + break; + } + i++; + } + if(flag) + { + printf("\n[输入有误!请重新输入]:"); + } + }while(flag); +// printf("%s",c); +// printf("\n%d",flag); + + i=0; + while(c[i]!='\0') + { + num=num*10+number(c[i]); + i++; + } +// printf("%lld",num);//-----调试用代码 + return num; +} +//------------------------------------------------------------------ + + + +//------------------------判断平年闰年函数-------------------------- +int is_Ryear(ll int year) +{ + if(year%4==0&&year%100!=0||year%400==0){ + return 1; + } + else{ + return 0; + } +} +//------------------------------------------------------------------ + + + +//--------------------------检测日期是否合法-------------------------- +int rule(ll int y,int m,int d) +{ + if((y<0||m<0||d<0)||(m>12)||((m==1||m==3||m==5||m==7||m==8||m==10||m==12)&&d>31)||((m==4||m==6||m==9||m==11)&&d>30)||is_Ryear(y)&&(m==2)&&(d>29)||(y==1582&&m==10&&(d>=5&&d<=14))) + { + return 1; + } + else{ + return 0; + } +} +//------------------------------------------------------------------- + + + +//--------------------------计算星期_返回星期几----------------------- +int week(ll int y,int m,int d) +{ + int w=0,y2; + ll int c; +// ll int c=y%100; + if(m==1||m==2) + { + m+=12; + y-=1; + } + + y2=y%100; + c=y/100; + //网上查的公式...... + if(y==1582&&m==10&&d<=4||y==1582&&m<=9||y<=1581) + { +// +// 儒略历计算公式:W = (5-C) + y + [y/4] + [13 * (M+1) / 5] + d - 1; + + w=(y2+y2/4+c/4-2*c+(26*(m+1))/10+d-1+10)%7; + + } + else//----1582年之后 + { +// w=(d+1+2*m+3*(m+10)/5+y+y/4+7)%7; +// w=(y2+(y2/4)+(c/4)-2*c+(26*(m+1)/10)+d-1)%7; +//蔡勒公式:w=y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1 + w=(y2+y2/4+c/4-2*c+(26*(m+1))/10+d-1)%7; + } + return w; +} +//------------------------------------------------------------------- + + + +//---------------------------返回月份对应天数------------------------- +int month(ll int y,int m) +{ + int d; + if(m==1||m==3||m==5||m==7||m==8||m==10||m==12) + { + d=31; + } + else if(m==4||m==6||m==9||m==11) + { + d=30; + } + else if(m==2&&is_Ryear(y)) + { + d=29; + } + else + { + d=28; + } + return d; +} +//------------------------------------------------------------------- + + + +//-----------------------画日历函数__单列----------------------------- +int pic_s(ll int y,int m,int w,int d) +{ + int k=0; + int f=0; + + printf("\n|***************************************************|"); + printf("\n|%lld年%d月|",y,m); + printf("\n 日\t 一\t 二\t 三\t 四\t 五\t 六\n "); +// printf(" "); + f=0; + for(int i=0;i=d_1)&&(k_2=d_1)&&(k_2=4&&m!=12) + { + flag=0; + printf("\n[按下任意健继续......]"); + getch(); + } + } + + Press_to_continue(); +} +//------------------------------------------------------------------- + + + +//-------------------------功能二__双列----------------------------- +int fun2_d(ll int y,int w) +{ + int m,d1,d2,flag=0,w_2; + printf("\033c"); + printf("\033[2J"); + printf("\033[0m"); + printf("\n|*****************************************|"); + printf("\n|*****公元%lld年历*****|",y); + for(m=1;m<=11;m+=2) + { + d1=month(y,m); + d2=month(y,m+1); + pic_d(y,m,w,d1,d2); + + if(y==1582&&m==9) + { + w_2=(w+d1-10)%7; + } + else + { + w_2=(w+d1)%7; + } + w=(w_2+d2)%7; + + flag+=1; + if(flag>=4&&m!=12) + { + flag=0; + printf("\n[按下任意健继续......]"); + getch(); + + } + } + + Press_to_continue(); +} +//------------------------------------------------------------------- + + + +//---------------------------菜单函数--------------------------------- +int start_10k() +{ +// int flagm=1; + printf("\033c");//-------------清屏函数 +// printf("\033[2J");//-------------清屏函数 +// printf("\033[0m");//------------结束状态函数 + +// while(flagm==1) +// { +// flagm=1; + + int p; + + printf("\n|*************欢迎使用万年历**************|"); + printf("\n|*****************************************|"); + printf("\n| 请选择功能: |"); + printf("\n| 1.星期查询 |"); + printf("\n| 2.年历查询 |"); + printf("\n| |"); + printf("\n| 0.退出程序 |"); + printf("\n|*****************************************|"); + + printf("\n[请输入您要使用的功能]:"); + p=(int)input(); +//------旧版输入,输入字母后会无限循环(有BUG) +// scanf("%d",&p); +// while(!(p==0||p==1||p==2)) +// { +// printf("\n[输入有误!请重新输入]"); +// printf("\n[请输入您要使用的功能]:"); +// scanf("%d",&p); +// } + + switch(p) + { + + case 1: printf("\033c"); +// printf("\033[2J");//------------清屏函数 +// printf("\033[0m\n");//------------结束状态函数 + fun_1(); + return 1; + break; + + case 2: printf("\033c"); +// printf("\033[2J");//------------清屏函数 +// printf("\033[0m\n");//------------结束状态函数 + fun_2_menu(); + return 1; + break; + + case 0: return 0; +// flagm=0; + break; + } +// } +// printf("\n|***************感谢您的使用**************|\n"); + return 1; +} +//------------------------------------------------------------------- + + + + + + + +//-----------------------------主函数----------------------------------- +int main() +{ + int flag; + printf("万年历\n 制作者:吕亦杰"); + Press_to_continue(); + do + { + flag=start_10k(); + }while(flag); + printf("\n|***************感谢您的使用**************|\n"); +} diff --git a/stu2024/软件2402唐凯杰.cpp b/stu2024/软件2402唐凯杰.cpp new file mode 100644 index 0000000..3b3ba9e --- /dev/null +++ b/stu2024/软件2402唐凯杰.cpp @@ -0,0 +1,342 @@ +#include +int main(){ + int flag=0; + while(flag==0){ + + printf("menu \n"); + printf("1:ѯijijijյܼ\n"); + printf("2:ǷΪ\n"); + printf("3:һ\n"); + printf("4:˳\n"); + + + char x[1]; + scanf("%s",&x[1]); + + + + if(x[1]!=49&&x[1]!=50&&x[1]!=51&&x[1]!=52) + printf("\n"); + + + if(x[1]==49){ + int w,d,m,y; + printf(" \n"); + scanf("%d%d%d",&y,&m,&d); + if(y<0||m<0||d<0||m>12||((m==1||m==3||m==5||m==7||m==8||m==10||m==12)&&d>31)||((m==2||m==4||m==9||m==11)&&d>30)||((y%4==0&&y%100!=0||y%400==0)&&m==2&&d>29)||(y==1582&&m==10&&(d==5||d==6||d==7||d==8||d==9||d==10||d==11||d==12||d==13||d==14))){ + printf("ڲ,\n"); + } + else{ + if(y<=1582&&m<=10&&d<=4){ + if(m==1||m==2){ + y--; + m+=12; + } + w = (d+1+2*m+3*(m+1)/5+y+y/4+5) % 7; + } + else{ + + if(m==1||m==2){ + y--; + m+=12; + } + + w = (d + 1+ 2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;} + switch(w){ + case 0:printf("\n");break; + case 1:printf("һ\n");break; + case 2:printf("ڶ\n");break; + case 3:printf("\n");break; + case 4:printf("\n");break; + case 5:printf("\n");break; + case 6:printf("\n");break; + + } + } + } + if(x[1]==50){ + int n; + printf("\n"); + scanf("%d",&n); + if(n%4==0&&n%100!=0||n%400==0){ + printf("%d\n",n); + } + else{ + printf("%d겻\n",n); + } + } + if(x[1]==51){ + int y; + printf("\n"); + scanf("%d",&y); + if(y<=0){ + printf("\n"); + } + else{ + printf("1:\n2:˫\n"); + int n,m,w,j,d,s,m1,m2,w1,w2,s1,s2,d1,d2,j1,j2; + scanf("%d",&n); + if(n==1){ + printf("%d\n",y); + for(m=1;m<=12;m++){ + printf("%d\n",m); + if(y<=1582&&m<=10){ + if(m==1||m==2){ + y--; + m+=12; + } + w = (1+1+2*m+3*(m+1)/5+y+y/4+5) % 7; + } + else{ + + if(m==1||m==2){ + y--; + m+=12; + } + + w = (1 + 1+ 2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;} + if(m==13||m==14){ + y++; + m-=12; + } + int month_days[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + if(y%4==0&&y%100!=0||y%400==0){ + month_days[2]=29; + } + s=month_days[m]; + printf(" sum mon tue wed thu fri sat\n"); + for(j=0;j=5&&d<=14) + continue; + + + + + printf("%4d",d); + + + if(y==1582&&m==10){ + + if(d==16||d==23||d==30){ + + + + printf("\n"); + } + + } + + + else if((d+w)%7==0){ + + + + printf("\n"); + } + } + if((s+w)%7!=0){ + printf("\n"); + } + } + } + else if(n==2){ + printf("%d\n",y); + for(m1=1,m2=2;m1<=11,m2<=12;m1+=2,m2+=2){ + + int aaa=1,cnt=1; + + printf("%d %d\n",m1,m2); + if(y<=1582&&m1<=10){ + if(m1==1||m1==2){ + y--; + m1+=12; + } + w1 = (1+1+2*m1+3*(m1+1)/5+y+y/4+5) % 7; + } + else{ + + if(m1==1||m1==2){ + y--; + m1+=12; + } + + w1 = (1 + 1+ 2*m1+3*(m1+1)/5+y+y/4-y/100+y/400)%7;} + if(m1==13||m1==14){ + y++; + m1-=12; + } + + if(y<=1582&&m2<=10){ + if(m2==1||m2==2){ + y--; + m2+=12; + } + w2 = (1+1+2*m2+3*(m2+1)/5+y+y/4+5) % 7; + } + else{ + + if(m2==1||m2==2){ + y--; + m2+=12; + } + + w2 = (1 + 1+ 2*m2+3*(m2+1)/5+y+y/4-y/100+y/400)%7;} + if(m2==13||m2==14){ + y++; + m2-=12; + } + + + + + + + int month_days[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + if(y%4==0&&y%100!=0||y%400==0){ + month_days[2]=29; + } + s1=month_days[m1]; + s2=month_days[m2]; + printf(" sum mon tue wed thu fri sat sum mon tue wed thu fri sat\n"); + + + + + + + + + + + + + + + for(j1=0;j1=5&&d1<=14) + continue; + + + + + printf("%4d",d1); + + + if(y==1582&&m1==10){ + + if(d1==16||d1==23||d1==30){ + + + + printf(" "); + + + + + + + + } + + } + + + else if((d1+w1)%7==0){ + + + + printf(" "); + + + + while(aaa){ + + for(j2=0;j2=5&&d2<=14) + continue; + + + + + printf("%4d",d2); + + + if(y==1582&&m2==10){ + + if(d2==16||d2==23||d2==30){ + + + + printf("\n"); + } + + } + + + else if((d2+w2)%7==0){ + + + + cnt=d2+1; + printf("\n"); + break; + + if(cnt!=d2){ + + printf("\n");} + } + } + + } + + + + + } + if((s1+w1)%7!=0){ + + + for(j1=0;j1<7-(s1+w1)%7;j1++){ + + + printf(" "); + } + + + printf(" \n"); + + if((s2+w2)%7!=0){ + printf("\n"); + } + + } + + + + } + printf("\n"); + } + } + } + + + if(x[1]==52){ + flag++; + } +} +} + diff --git a/stu2024/软件2402田世涛.cpp b/stu2024/软件2402田世涛.cpp new file mode 100644 index 0000000..acb11c8 --- /dev/null +++ b/stu2024/软件2402田世涛.cpp @@ -0,0 +1,125 @@ +#include + +// 判断闰年 +int isLeapYear(int year) { + return ((year % 4 == 0 && year % 100!= 0) || year % 400 == 0); +} + +// 计算给定日期是周几(蔡氏公式) +int dayOfWeek(int year, int month, int day) +{ + if (month < 3) { + year--; + month += 12; + } + int c = year / 100; + int y = year % 100; + int d = (day + (13 * (month + 1) / 5) + y + (y / 4) + (c / 4) + (5 * c)) % 7; + return d; +} + +// 输出单列日历 +void printSingleColumnCalendar(int year) {//printSingleColumnCalendar打印单个月日历空间 + char *months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; + int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};//储存一年每月的天数 + if (isLeapYear(year)) { + daysInMonth[1] = 29;//特殊年份 + } + for (int m = 0; m < 12; m++) {//输出一年的月份 + printf("%s %d\n", months[m], year); + printf("Sun Mon Tue Wed Thu Fri Sat\n"); + int weekDay = dayOfWeek(year, m + 1, 1); + for (int i = 0; i < weekDay; i++) { + printf(" "); + } + for (int d = 1; d <= daysInMonth[m]; d++) { + printf("%3d ", d); + if ((weekDay + d) % 7 == 0) { + printf("\n"); + } + } + printf("\n\n"); + } +} + +// 输出双列日历 +void printDoubleColumnCalendar(int year) {//printDoubleColumnCalendar打印并排月的日历 + char *months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; + int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (isLeapYear(year)) { + daysInMonth[1] = 29; + } + for (int m = 0; m < 12; m++) { + printf("%s %d\t\t", months[m], year); + if (m % 2 == 0) { + printf("\n"); + } + printf("Sun Mon Tue Wed Thu Fri Sat\t\tSun Mon Tue Wed Thu Fri Sat\n"); + int weekDay = dayOfWeek(year, m + 1, 1); + for (int i = 0; i < weekDay; i++) { + printf(" "); + } + for (int d = 1; d <= daysInMonth[m]; d++) { + printf("%3d ", d); + if ((weekDay + d) % 7 == 0) { + printf("\n"); + } + } + printf("\n\n"); + } +} + +// 菜单显示 +void menu() { + int choice, year,a; + printf("1.输出对应年份全年的日历:\n"); + printf("2.判断输入年份是否为闰年:\n"); + printf("3.对应日期为周几:\n"); + printf("4.退出:\n"); + scanf("%d",&a); + if(a==1) + { + printf("1. 输出单列日历\n2. 输出双列日历\n3. 退出\n: "); + scanf("%d", &choice); + if (choice == 1 || choice == 2) { + printf("请输入年份: "); + scanf("%d", &year); + if (year < 1900 || year > 2100) {//报错范围 + printf("年份超出范围,请重新输入\n"); + menu(); + return; + } + if (choice == 1) { + printSingleColumnCalendar(year);//选择单列 + } else { + printDoubleColumnCalendar(year);//选择双列 + } + } else if (choice == 3) { + return; + } else { + printf("无效选择,请重新选择\n"); + menu(); + } +} + else if(a==2) + { + printf("请输入年份:\n"); + scanf("%d",&year); + if((year % 4 == 0 && year % 100!= 0) || year % 400 == 0) + printf("闰年"); + else + printf("平年"); + } + else if(a==3) + { + + +} + } + + +int main() { + + menu(); + return 0; +} \ No newline at end of file diff --git a/stu2024/软件2403王琬琳.cpp b/stu2024/软件2403王琬琳.cpp new file mode 100644 index 0000000..a69960a --- /dev/null +++ b/stu2024/软件2403王琬琳.cpp @@ -0,0 +1,171 @@ +#include +//̨ûʵ˫ 1582ʮ +void k( int x,int year,int month) + { int i,day=0,j; + for(i=0;i=5&&day<=14) + { + printf("\n"); + while(month++<=12) + { + switch(month) + { + case 1: case 3: case 5: case 7: case 8: case 10: case 12: + x=31; + weed(month,year); + k(x,year,month); + break; + case 4: case 6: case 9: case 11: + x=30; + weed(month,year); + k(x,year,month); + break; + case 2: + if(year%4==0&&year%100!=0||year%400==0) + x=29; + else + x=28; + weed(month,year); + k(x,year,month); + } + } + } + else + printf("\n"); + while(month++<=12) + { + switch(month) + { + case 1: case 3: case 5: case 7: case 8: case 10: case 12: + x=31; + weed(month,year); + k(x,year,month); + + break; + case 4: case 6: case 9: case 11: + x=30; + weed(month,year); + k(x,year,month); + break; + case 2: + if(year%4==0&&year%100!=0||year%400==0) + x=29; + else + x=28; + weed(month,year); + k(x,year,month); + break; + } + } + + + + + + } + +} +} diff --git a/stu2024/软件2404李建瑞 第二次.cpp b/stu2024/软件2404李建瑞 第二次.cpp new file mode 100644 index 0000000..11e1616 --- /dev/null +++ b/stu2024/软件2404李建瑞 第二次.cpp @@ -0,0 +1,565 @@ +#include +char *mmmm[13]={" ","January","February","March","April","May","June","July","August","September","October","November","December"}; +int xingqi(int year,int month) + { + if (month==1||month==2) + { + month=month+12; + year=year-1; + } + int a=year%100; + int b=year/100; + int day=1; + int h=(day+13*(month+1)/5+a+a/4+b/4+5*b)%7; + int d=(h+6)%7; + return d; +} + + +int xingqi2(int year,int month,int d) +{ + if (month==1||month==2) + { + month=month+12; + year=year-1; + } + int c=year/100; + int y=year%100; + int a=(c/4-2*c+y+y/4+13*(month+1)/5+d-1)%7; + if(a==0) + a=7; + return a; +} + + +int main(void) +{ + int s; + do{ + int qwe; + printf("*********************************************************\n"); + printf("˵:\n"); + printf("1ѯӦݵ\n"); + printf("2:ѯӦڵ\n"); + printf("3:ѯӦǷΪ\n"); + printf("4:ѯ·Ӣô\n"); + printf("*********************************************************"); + printf("\n\n"); + + + while(2) + { + printf("еĹܱΪ:\n"); + scanf("%d",&qwe); + if(qwe>0&&qwe<5) + break; + else + printf("δù \n\n"); + } + + + + + + if(qwe==1) + { + int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + int n[13]={0,1,2,3,4,5,6,7,8,9,10,11,12}; + int year,a,b,c; + while(2) + { + printf("ѯ:\n"); + scanf("%d",&year); + if(year>0) + break; + else + printf(" \n"); + } + if(year%4==0&&year%100!=0||year%400==0) + m[2]=29; + if(year==1582) + m[10]=21; + a=year/100; + b=year%100; + int ds; + while(2) + { + printf("1\n˫2\n"); + scanf("%d",&ds); + if(ds==1||ds==2) + break; + else + printf(" \n"); + } + if(year!=1582) + { + if(ds==2) + { + for(int nn=1;nn<13;nn=nn+2) + { + int day1=1,day2=1; + int ll; + int c,d,e,f,g; + c=xingqi(year,nn); + d=xingqi(year,nn+1); + f=(m[nn]+c-1)/7+1; + g=(m[nn+1]+d-1)/7+1; + if(f>g) + e=f; + else + e=g; + printf(" һ һ \n"); + printf("%d %d\n",n[nn],n[nn+1]); + for(ll=0;llg) + e=f; + else + e=g; + printf(" һ һ \n"); + printf("%d %d\n",n[nn],n[nn+1]); + if(nn!=11) + { + for(ll=0;ll4) + { + printf("%2d ",day2+10); + day2++; + } + else + printf(" "); + } + } + printf("\n"); + } +} + + if(nn==11) + { + + + f=(m[nn]+c+4-1)/7+1; + g=(m[nn+1]+d+4-1)/7+1; + if(f>g) + e=f; + else + e=g; + + for(ll=0;ll4) + { + printf("%2d ",day2+10); + day2++; + } + else + printf(" "); + } + } + printf("\n"); + } +} + + + + } + printf("\n"); + } + else + { + if(year!=1582) + { + for(int nn=1;nn<13;nn++){ + printf(" һ \n"); + printf("%d\n",n[nn]); + c=xingqi(year,nn); + for(int aa=0;aa0) + break; + else + printf("빫Ԫ\n\n"); + } + int c; + while(2) + { + printf("ѯ·Ϊ:\n"); + scanf("%2d",&c); + while(getchar()!='\n'); + if(c>0&&c<13) + break; + else + printf("ȷ·\n\n"); + } + int d; + while(2) + { + printf("ѯĺΪ:\n"); + scanf("%2d",&d); + while(getchar()!='\n'); + if(year!=1582) + { + if(c==2) + { + if(year%4==0&&year%100!=0||year%400==0) + { + if(d>0&&d<30) + break; + else + printf("ȷ\n\n"); + } + else + { + if(d>0&&d<29) + break; + else + printf("ȷ\n\n"); + } + } + else if(c==1||c==3||c==5||c==7||c==8||c==10||c==12) + { + if(d>0&&d<32) + break; + else + printf("ȷ\n\n"); + } + else + if(d>0&&d<31) + break; + else + printf("ȷ\n\n"); + +} + + +if(year==1582) + { + if(c==2) + { + if(year%4==0&&year%100!=0||year%400==0) + { + if(d>0&&d<30) + break; + else + printf("ȷ\n\n"); + } + else + { + if(d>0&&d<29) + break; + else + printf("ȷ\n\n"); + } + } + else if(c==1||c==3||c==5||c==7||c==8||c==12) + { + if(d>0&&d<32) + break; + else + printf("ȷ\n\n"); + } + else if(c==10) + { + if(d>0&&d<5||d>14&&d<32) + break; + else + printf("ȷ\n\n"); + } + else + if(d>0&&d<31) + break; + else + printf("ȷ\n\n"); + +} + + + } + int e; + e=xingqi2(year,c,d); + if(e==0) + e==7; + if(year!=1582){ + printf("ѯΪ%d\n",e); +} +else +{ + if(c!=10&&c!=11&&c!=12) + printf("ѯΪ%d\n",e); + else if(c==10) + { + if(d<5) + printf("ѯΪ%d\n",e); + else + printf("ѯΪ%d\n",e-3); + } + + else if(c==11) + { + int e; + e=xingqi2(year,c,d)+4; + if(e==0) + e=7; + if(e==8) + e=1; + if(e==9) + e=2; + if(e==10) + e=3; + if(e==11) + e=4; + printf("ѯΪ%d\n",e); + } + else { + int e; + e=xingqi2(year,c,d)-3; + if(e==-1) + e=6; + if(e==-2) + e=5; + if(e==0) + e=7; + printf("ѯΪ%d\n",e); + } +} + } + + else if(qwe==3) + { + int year; + while(2) + { + printf("Ҫѯݣ\n"); + scanf("%d",&year); + if(year>0) + break; + else + printf("빫Ԫ\n\n"); + } + if(year%4==0&&year%100!=0||year%400==0) + printf("%d",year); + else + printf("%d",year); + } + + else + { + int yuefen; + do{ + printf("ѯ·ݣð:\n"); + scanf("%d",&yuefen); + }while(yuefen<1||yuefen>12); + printf("%dӢʾΪ %s\n",yuefen,mmmm[yuefen]); + } +printf("Ƿ\n 밴1 밴1Ⱒ\n"); +scanf("%d",&s); +}while(s==1); + return 0; +} diff --git a/stu2024/软件2404潘仕博.cpp b/stu2024/软件2404潘仕博.cpp new file mode 100644 index 0000000..38c01df --- /dev/null +++ b/stu2024/软件2404潘仕博.cpp @@ -0,0 +1,143 @@ +#include +#include + +// жǷΪ +int runnian(int year) { + return ((year % 4 == 0 && year % 100!= 0) || (year % 400 == 0)); +} + +// ijܼķɭ㹫ʽ +int howweek(int year, int month, int day) { + if (month < 3) { + month += 12; + year--; + } + int week = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400) % 7; + return week+1; +} + +// · +void dl(int year, int month) { + int dym; + if (month == 2) { + dym = runnian(year)? 29 : 28; + } else if (month == 4 || month == 6 || month == 9 || month == 11) { + dym = 30; + } else { + dym = 31; + } + + int weekDay = howweek(year, month, 1); + if(weekDay==7) + weekDay=0; + printf(" %d%d\n", year, month); + printf(" һ \n"); + + for (int i = 0; i < weekDay; i++) { + printf(" "); + } + for (int i = 1; i <= dym; i++) { + printf("%2d ", i); + if ((i + weekDay) % 7 == 0) { + printf("\n"); + } + } + printf("\n"); +} + + // գ +void dl(int year) { + if(year<=10000&&year>0){ + for (int month = 1; month <= 12; month++) { + dl(year, month); + } +} +else +printf(""); +} + +// ʾ˵ +void cd() { + printf("1. ѯܼǷ\n"); + printf("2. У\n"); + printf("3. ˫У\n"); + printf("4. ˳\n"); + printf("ѡ"); +} +int getValidIntInput() { + int input; + while (1) { + if (scanf("%d", &input) == 1) { + break; + } else { + printf(""); + while (getchar()!= '\n'); + } + } + return input; +} + +int main() { + int choice; + int year, month, day; + + do { + cd(); + choice = getValidIntInput(); + + switch (choice) { + case 1: + printf("ݣ"); + year = getValidIntInput(); + printf("·ݣ"); + month = getValidIntInput(); + printf("ڣ"); + day = getValidIntInput(); + + printf("%d%d%d", year, month, day); + switch (howweek(year, month, day)) { + case 0: + printf(""); + break; + case 1: + printf("һ"); + break; + case 2: + printf(""); + break; + case 3: + printf(""); + break; + case 4: + printf(""); + break; + case 5: + printf(""); + break; + case 6: + printf(""); + break; + } + printf(""); + if (runnian(year)) { + printf("\n"); + } else { + printf("겻\n"); + } + break; + case 2: + printf("ݣ"); + year =getValidIntInput(); + dl(year); + break; + case 4: + printf("˳\n"); + break; + default: + printf("Чѡѡ\n"); + break; + } + } while (choice!= 4); + + return 0; +} diff --git a/stu2024/软件2404王莫涵(1).cpp b/stu2024/软件2404王莫涵(1).cpp new file mode 100644 index 0000000..e142a42 --- /dev/null +++ b/stu2024/软件2404王莫涵(1).cpp @@ -0,0 +1,382 @@ +#include +using namespace std; + +bool run(int year) { + if (year >= 1582) + return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; + else + return (year % 4 == 0); +} + +bool Y(int year) { + if (year > 0 && year < 10000) + return true; + else + return false; +} +bool M(int month) { + if (month > 0 && month < 13) + return true; + else + return false; +} +bool D(int year, int month, int day) { + int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (run(year)) + m[2] = 29; + if (year == 1582 && month == 10 && day >= 5 && day < 15) + return false; + if (!(day > 0 && day <= m[month])) + return false; + return true; +} + +int shu(char a[100]) { + int c, t = strlen(a); + for (int i = 0; i < t; i++) { + if (a[i] >= '0' && a[i] <= '9') { + c++; + } else { + return false; + } + } + if (c == t) + return true; +} + + +int zhou(int year, int month, int day) { + int a, b = 0; + int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + a = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400) + 1) % 7; + if (year <= 1582) { + a = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400) + 11) % 7; + } + if (run(year)) + m[2] = 29; + if (year == 1582) { + m[10] = 21; + } + for (int i = 1; i < month; i++) { + + a = (a + m[i]) % 7; + } + if (year == 1582 && month == 10 && day >= 15) { + b = (day - 10) % 7; + } else + b = (a + day - 1) % 7; + return b; +} + + + +void one(int year, int month) { + printf("%6d%6d\n", year, month); + cout << " һ \n"; + + int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (run(year)) + m[2] = 29; + + int d1 = zhou(year, month, 1); + + + + int day = 1; + for (int i = 1; i <= d1; i++) { + cout << " "; + } + while (day <= m[month]) { + if (year == 1582 && month == 10 && day == 5) { + day += 10; + d1 += 11; + } + cout << setw(2) << day << " "; + + + if ((day + d1 ) % 7 == 0 && day != m[month]) { + + + cout << "\n"; + } + day++; + } + cout << "\n"; + +} + +//˫ +void two2(int year, int month, int *n) { + int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (run(year)) + m[2] = 29; + int i; + if (*n == 1) { + int z = zhou(year, month, 1); + //if(z==0)z=7; + for (i = 1; i <= z ; i++) { + cout << " "; + } + } + + for (i = *n ; i <= m[month]; i++) { + printf ("%3d ", i); + + + if ((i + zhou(year, month, 1) ) % 7 == 0 || i == m[month] ) { + + + cout << "\n"; + *n = i + 1; + break; + } + } +} +void two(int year, int month) { + int i, n = 1; + int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + if (run(year)) + m[2] = 29; + + printf("%9d%6d", year, month); + printf("%35d%6d\n", year, month + 1); + printf(" һ һ \n"); + int z = zhou(year, month, 1); + //if (z == 0)z = 7; + for (i = 1; i <= z; i++) { + printf(" "); + } + for (i = 1; i <= m[month]; i++) { + printf("%3d ", i); + + + if ((i + zhou(year, month, 1) ) % 7 == 0 || i == m[month]) { + + + if (i == m[month]) { + int w; + w = 7 - ( (i + zhou(year, month, 1) ) % 7 ); + if (w != 7) { + for (int i = 1; i <= w; i++) + printf(" "); + } + } + cout << " "; + two2(year, month + 1, &n); + } + } + printf(" "); + two2(year, month + 1, &n); +} + +//˵ +int screen() { + char a[10000]; + int b = 9; + + cout << "˵\n"; + cout << "1.ѯijijijյܼǷΪ\n"; + cout << "2.ݣһ\n"; + cout << "3.ݣ˫һ\n"; + cout << "4. 0 Խ\n"; + cout << "ѡ"; + cin >> a; + + if (strlen(a) > 1) { + return b; + } else { + + if (a[0] <= '9' && a[0] >= '0') { + system("cls"); + b = a[0] - '0'; + return b; + } else { + system("cls"); + return b; + } + + } +} + +int main() { + int c; + char y[100] = {0}, m[100] = {0}, d[100] = {0}; + do { + c = screen(); + switch (c) { + case 1: { + int year, month, day; + cout << "ݣ"; + cin >> y; + if (strlen(y) > 4) { + cout << "롣\n"; + continue; + } + if (shu(y)); + else { + cout << "롣\n"; + continue; + } + + + if (strlen(y) == 4) + year = 1000 * (y[0] - '0') + 100 * (y[1] - '0') + 10 * (y[2] - '0') + (y[3] - '0'); + if (strlen(y) == 3) + year = 100 * (y[0] - '0') + 10 * (y[1] - '0') + 1 * (y[2] - '0'); + if (strlen(y) == 2) + year = 10 * (y[0] - '0') + (y[1] - '0'); + if (strlen(y) == 1) + year = 1 * (y[0] - '0'); + if (!Y(year)) { + cout << "롣\n"; + continue; + } + + + + cout << "·ݣ"; + cin >> m; + if (strlen(m) > 2) { + cout << "·롣\n"; + continue; + } + if (shu(m)); + else { + cout << "·롣\n"; + continue; + } + if (strlen(m) == 2) + month = (10 * (m[0] - '0') + (m[1] - '0')); + if (strlen(m) == 1) + month = (m[0] - '0'); + + + if (!M(month)) { + cout << "·롣\n"; + continue; + } + + + + + cout << "ڣ"; + cin >> d; + if (strlen(d) > 2) { + cout << "롣\n"; + continue; + } + if (shu(d)); + else { + cout << "롣\n"; + continue; + } + if (strlen(d) == 2) + day = (10 * (d[0] - '0') + (d[1] - '0')); + if (strlen(d) == 1) + day = (d[0] - '0'); + + + if (!D(year, month, day)) { + cout << "롣\n"; + continue; + } + + + int z = zhou(year, month, day); + if (zhou(year, month, day) == 0) + z = 7; + cout << year << "" << month << "" << day << "" + << z << "\n"; + + if (run(year)) { + cout << year << "ꡣ\n"; + break; + } else { + cout << year << "겻ꡣ\n"; + break; + } + } + + case 2: { + int year; + + cout << "ݣ"; + cin >> y; + if (strlen(y) > 4) { + cout << "롣\n"; + continue; + } + if (shu(y)); + else { + cout << "롣\n"; + continue; + } + if (strlen(y) == 4) + year = 1000 * (y[0] - '0') + 100 * (y[1] - '0') + 10 * (y[2] - '0') + (y[3] - '0'); + if (strlen(y) == 3) + year = 100 * (y[0] - '0') + 10 * (y[1] - '0') + 1 * (y[2] - '0'); + if (strlen(y) == 2) + year = 10 * (y[0] - '0') + (y[1] - '0'); + if (strlen(y) == 1) + year = 1 * (y[0] - '0'); + if (!Y(year)) { + cout << "롣\n"; + continue; + } + + for (int month = 1; month <= 12; month++) { + one(year, month); + } + break; + } + + case 3: { + int year; + + cout << "ݣ"; + cin >> y; + if (strlen(y) > 4) { + cout << "롣\n"; + continue; + } + if (shu(y)); + else { + cout << "롣\n"; + continue; + } + if (strlen(y) == 4) + year = 1000 * (y[0] - '0') + 100 * (y[1] - '0') + 10 * (y[2] - '0') + (y[3] - '0'); + if (strlen(y) == 3) + year = 100 * (y[0] - '0') + 10 * (y[1] - '0') + 1 * (y[2] - '0'); + if (strlen(y) == 2) + year = 10 * (y[0] - '0') + (y[1] - '0'); + if (strlen(y) == 1) + year = 1 * (y[0] - '0'); + if (!Y(year)) { + cout << "롣\n"; + continue; + } + for (int month = 1; month <= 12; month += 2) { + if (year == 1582 && month == 9) { + month = 11; + cout << " 1582 9 1582 10\n һ һ \n"; + cout << " 1 1 2 3 4 15 16\n"; + cout << " 2 3 4 5 6 7 8 17 18 19 20 21 22 23\n"; + cout << " 9 10 11 12 13 14 15 24 25 26 27 28 29 30\n"; + cout << " 16 17 18 19 20 21 22 31\n"; + cout << " 23 24 25 26 27 28 29\n 30\n"; + } + two(year, month); + printf("\n\n"); + } + + break; + } + case 0: { + return 0; + } + default: + cout << "롣\n"; + } + } while (true); +} diff --git a/stu2024/软件2404班钟浩峻.cpp b/stu2024/软件2404班钟浩峻.cpp new file mode 100644 index 0000000..d832be6 --- /dev/null +++ b/stu2024/软件2404班钟浩峻.cpp @@ -0,0 +1,157 @@ +#include +//ж껹ƽ +int isleapyear(int year){ + if(year%400==0&&year%4==0&&year%100!=0) + return 0;// + else + return 1;//ƽ +} +//ʾָڶӦڼֹʽ +int getDayOfweek(int year,int month,int day){ +if(month<3){ + year--; + month+=12;} + int k = year % 100; + int j = year / 100; + int h = (j/ 4 - 2 * j + k + k / 4 + 13 * (month + 1) / 5 + day - 1); + h= h % 7; + if (h < 0) + h += 7; + return h; +} +// +//ʾָ +void sureyearcarlender(int year,int isdoubleline){ +int monthday[]={31,31,28+isleapyear(year),31,30,31,30,31,30,31,30,31,30}; + printf("%d\n",year); +for(int month=1;month<=12;month++){ + + printf("\n%d\n",month); + printf(" һ \n"); + //жµ1ܼ + int empty,dateweek=getDayOfweek(year,month,1); + + //1ǰĿո + for(empty=0;empty +#include +void caidan(void) +{ + printf("1.ѯӦݵ\n"); + printf("2.ѯӦڵ\n"); + printf("3.ѯӦǷΪ\n"); + printf("4.˳\n\n"); +} +int fang() +{ + int t; + while(scanf("%d",&t)!=1) + { + printf("\n"); + while(getchar()!='\n'); + } + return t; +} +void riqi() +{ + int y,m,d,q,xingqi; + printf("ڣ"); + scanf("%d",&y); + scanf("%d",&m); + scanf("%d",&d); + if(y<1||y>10000||m<1||m>12||d<1||((m==1||m==3||m==5||m==7||m==8||m==10||m==12)&&d>31)||((m==4||m==6||m==9||m==11)&&d>30)||(m==2&&d>29)) + { + printf("\n"); + while(scanf("%d",&y)!=1||scanf("%d",&m)!=1||scanf("%d",&d)!=1) + { + printf("\n"); + while(getchar()!='\n'); + } + } + + xingqi=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7; + xingqi++; + switch(xingqi) + { + case 1:printf("һ");break; + case 2:printf("ڶ");break; + case 3:printf("");break; + case 4:printf("");break; + case 5:printf("");break; + case 6:printf("");break; + case 7:printf("");break; + } +} +int runnian() +{ + int year; + printf("ѯݣ"); + year=fang(); + if(year<0||year>100) + { + printf("\n"); + year=fang(); + } + if((year%4==0&&year%100!=0)||year%400==0) + printf("%d",year); + else + printf("%d겻",year); + return year; +} +int yihao(int year,int month) +{ + if(month<3) + { + year--; + month+=12; + } + int d=(1+2*month+3*(month+1)/5+year+year/4-year/100+year/400)%7; + d++; + return d; +} + +int danrili(int year) +{ + int month; + int x,n,s; + int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; + if((year%100!=0&&year%4==0)||year%400==0) + { + a[2]=29; + } + for(month=1;month<=12;month++) + { + printf("%2d\n",month); + printf(" һ \n"); + x=yihao(year,month); + if(year==1582&&month==10) + x=1; + for(int i=0;iv) + b=c; + else + b=v; + printf(" %2d %2d\n",month,month+1); + printf(" һ һ \n"); + for(j=0;j10000) + { + printf("\n"); + while(getchar()!='\n'); + } + printf("1\n˫2\n"); + while(scanf("%d",&o)!=1||o<1||o>2) + { + printf("\n"); + while(getchar()!='\n'); + } + switch(o) + { + case 1:danrili(p);break; + case 2:shuangrili(p);break; + } +} +int main() +{ + int n,year,month,day; + caidan(); + while(scanf("%d",&n)!=1||n<1||n>4) + { + printf("\n"); + while(getchar()!='\n'); + } + switch(n) + { + case 1:rili();break; + case 2:riqi();break; + case 3:runnian();break; + case 4:break; + } + return 0; +} diff --git a/stu2024/软件工程2403张灿冉(1).cpp b/stu2024/软件工程2403张灿冉(1).cpp new file mode 100644 index 0000000..126e899 --- /dev/null +++ b/stu2024/软件工程2403张灿冉(1).cpp @@ -0,0 +1,106 @@ +#include +int year1(int y) +{ + if((y%4==0)&&(y%100!=0)||y%400==0) + return 366; + else + return 365; +} +int main(void){ + int command; + printf("|-----------ӭʹ------------|\n"); + printf("|1.ѯӦ |\n"); + printf("|2.жǷΪ |\n"); + printf("|3.ѯӦ |\n"); + printf("|4.˳ |\n"); + printf("|-------------------------------|\n"); + do{ + printf("ѡĹܣ"); + scanf("%d",&command); + switch(command) + { + case 1: + int year,month,day,week; + printf("(мÿոָ):"); + scanf("%d%d%d",&year,&month,&day); + if(month==1||month==2){ + month+=12; + year--;} + week=(day+2*month+3*(month+1)/5+year+year/4-year/100+year/400)%7; + switch(week){ + case 0: + printf("һ\n"); + break; + case 1: + printf("ڶ\n"); + break; + case 2: + printf("\n"); + break; + case 3: + printf("\n"); + break; + case 4: + printf("\n"); + break; + case 5: + printf("\n"); + break; + case 6: + printf("\n"); + break; + } + break; + case 2: + int x; + printf(""); + scanf("%d",&x); + if(x%4==0&&x%100!=0||x%400==0) + printf("\n"); + else + printf("\n"); + break; + case 3: + { + int y,i,j,sum=0,z; + int begin,week; + int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; + printf(":"); + scanf("%d",&y); + printf("1. 2.˫\n"); + printf(":",z); + scanf("%d",&z) ; + if(z==1) + for(i=1;i +#include +//setfill() 填充 +//setw() 宽 +//setprecision()显示数字位数 + +using namespace std; + +class calendar +{ +public: + void Menu_present() + { + cout<<"This is a calendar"<> menu_number; + if (!cin.fail())break; + if (cin.fail()) { + cin.clear(); + cin.sync(); + cout << "Your input is illegal" << endl; + cout << "please input the number correctly" << endl; + cout << "other char is not allowed" << endl; + continue; + } + } + switch(menu_number) + { + case 1: M_Search(); + break; + case 2: Check(); + break; +// case 3: +// break; + case 88: + cout<<"Good bye,have a good day!"<> year; +// if(year<0){ +// //cin.clear(); +// cin.sync(); +// cout<<"year wrong"<> month; + if(!cin.fail()){ + if(month<1||month>12){ + cin.clear(); + cin.sync(); + cout<<"month wrong"<> day; +// if(day<1||day> month_judge(year,month)){cin.clear();cin.sync();cout<<"day wrong"< month_judge(year,month)){cin.clear();cin.sync();cout<<"day wrong"<4&&day<15))cout<<"This is none day"<> year; + if(!cin.fail()){ + if(year<0){ + cin.clear(); + cin.sync(); + cout<<"year wrong"<> c; + if(!cin.fail())break; + if (cin.fail()) { + cin.clear(); + cin.sync(); + cout << "Your input is illegal" << endl; + cout << "please input the number correctly" << endl; + cout << "other char is not allowed" << endl; + continue; + } + }//cin 选择 + switch(c) + { + case 1: + send1_12(year); + break; + case 2: + send2_6(year); + break; + default: + cout<<"Invalid input"<1582||((year==1582&&month>10)||(year==1582&&month==10&&day>4)))//geli + { + f=(day+2*month+3*(month+1)/5+year+year/4-year/100+year/400+1)%7; + if(f==0)f=7; + return f; + }else//ruli + { + f=(day+2*month+3*(month+1)/5+year+year/4-year/100+year/400+4)%7; + if(f==0)f=7; + return f; + } + }// 返回星期几 + void send1_12(int year){ + + for(int i=1;i<=12;i++)// 12个月 + { + + cout<