【卡雷尔杯】 星系炸弹- 王浩然(19103315)
作者:互联网
【卡雷尔杯】 星系炸弹- 王浩然(19103315)
代码
#include<iostream>
using namespace std;
bool isLeapYear(int year){
return (year%4==0&&year%100!=0)||(year%400==0);
}
int main(){
int month[13]={0,31,30,31,30,31,30,31,31,30,31,30,31};
int year=2014;
int days=1009;
for(int i=0;i<11;i++){
days+=month[i];
}
int yearDay=0;
while(true){
if(isLeapYear(year)){
yearDay=366;
}else{
yearDay=365;
}
if(days<yearDay){
break;//跳出循环
}
days-=yearDay;
year++;
}
while(true){
for(int i=1;i<13;i++){
if(days<month[i]){
cout<<year;
if(i<10){
cout<<"-0"<<i;
}else{
cout<<"-";
}
if(days<10){
cout<<"-0"<<days;
}else{
cout<<"-";
}
return 0;
}
days-=month[i];
}
}
return 0;}
excel
标签:30,int,31,卡雷尔,year,浩然,year%,19103315 来源: https://blog.csdn.net/m0_50860320/article/details/115742346