最近在做OJ的相关题,由于OJ系统检测内存和算法时间对Java很不利,因此转行学习C++,目前尚处于初学阶段,遇到08年上海交大的一题,题目不再复述,先贴代码吧。
#include <iostream> #include <string> #include <stdio.h> #define ISYEAR(x) (x%100!=0&&x%4==0)||(x%400==0)?1:0 using namespace std; int dayOfMonth[13][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30, 31,31, 31,31, 30,30, 31,31, 30,30, 31,31 }; struct Date{ int year; int month; int day; void nextDay(){ day++; if(day>dayOfMonth[month][ISYEAR(year)]){ month++; day=1; if(month>12){ year++; month=1; } } } }; string monthName[13]={ "","January","February","March","April","May","June","July","August","September",
c++中用scanf输入string的问题
最新推荐文章于 2025-03-01 16:21:08 发布