首页 > 其他分享 >打卡第二天

打卡第二天

时间:2023-04-13 21:11:29浏览次数:35  
标签:count int 天数 31 30 y% 第二天 打卡

问题:打鱼还是晒网

思路:用for循环分别求1991年到某年的前一年的天数,以及某年的1月到某月的前一月的天数,用数组存储每月的天数,注意闰年的判断条件和闰年天数的变换,利用五天为一组的周期性,用除余的方式得到结果。

代码:

#include<iostream>
using namespace std;
const int N=13;
int a[N]={31,28,31,30,31,30,31,31,30,31,30,31};
int b[N]={31,29,31,30,31,30,31,31,30,31,30,31};

int main()
{
int y,m,d;
cin>>y>>m>>d;
int count=0;
if(y>1991){
for(int i=1991;i<y;i++){
int k=0;
if(i%4==0&&i%100!=0||i%400==0){
k=366;
count=k+count;
}
else{
k=365;
count=k+count;
}
}
}
if(m>1){
for(int j=0;j<m-1;j++){
if(y%4==0&&y%100!=0||y%400==0)
count=count+b[j];
else
count=count+a[j];
}
}
count=count+d;
int f=count%5;
if(f>0&&f<4)
cout<<"打鱼";
else
cout<<"晒网";
return 0;
}

 

标签:count,int,天数,31,30,y%,第二天,打卡
From: https://www.cnblogs.com/Hugo-Martin/p/17316414.html

相关文章

  • 第三天打卡
    一、问题描述  输入一个数,判断其是否为素数二、设计思路  1.输入一个数a;  2.用循环统计从1到他本身因数count个数   3.若count为2,则输出yes,反之输出no三、程序流程图  四、代码实现#include<iostream>usingnamespacestd;intmain(){inta,cou......
  • 每日打卡
    //#include<iostream>//usingnamespacestd;//intfun(intn)//{//if(n<=4)//{//returnn;//}//else//{//returnfun(n-1)+fun(n-3);//}//}//intmain(void)//{//intn;//cin>>n;//while(n!=......
  • 打卡第二天
    7-7#include<iostream>#include<string>usingnamespacestd;classDocument{  private:   stringname;public:   Document(stringnam):name(nam)    {       cout<<"Name:"<<name<<endl;   }   ~Document(){} ......
  • 每日打卡-4.1
    一.问题描述定义计数器Counter类,对其重载运算符+二.设计思路设计counter类,包含属性i,然后重载运算符+,使其能够使两个counter类对象相加,返回一个counter类对象。三.流程图  四.伪代码 五.代码实现 #include<iostream>usingnamespacestd;classcounter......
  • 最新版人脸识别小程序 图片识别 生成码签到码 地图上选点进行位置签到 计算签到距离
    技术选型1,前端小程序原生MINA框架cssJavaScriptWxml2,管理后台云开发Cms内容管理系统web网页3,数据后台小程序云开发云函数云开发数据库(基于MongoDB)云存储4,人脸识别算法基于百度智能云实现人脸识别一,用户端效果图预览老规矩我们先来看效果图,如果效果图符合你的需求,就继续往下......
  • 第二天第四个问题
    问题描述:编写一个使用嵌套循环的程序,要求用户输入一个值,指出要显示多少行。然后程序将显示相应行数的星号,其中第一行包括一个星号,第二行包括两个星号,依次类推。每一行包含的字符数等于用户指定的行数,在星号不够的情况下,在星号前面加上句点。运行情况如下:enternumberofrows:5.......
  • 第二天第三个问题
    问题描述:编写上一个问题,但使用string对象而不是字符数组解决思路:于上个问题相同代码:#include<iostream>#include<cstring>#include<string>usingnamespacestd;intmain(){ stringa; stringb="done"; intans=0; cout<<"enterwords:"; cout<&......
  • 第二天打卡第二个问题
    问题描述:编写一个程序,它使用一个char数组和循环来每次读取一个单词,直到用户输入done为止。随后,该程序指出用户输入了多少个单词不包括done在内。下面是运行状况enterwords:anteaterbirthdaycategorydumpsterenvyfinaglegeometrydoneforsureyouenteredatotalof7......
  • c++打卡第四天
    一、题目描述。  实现一个简单的程序,运行时显示“Menu:A(dd) D(elete)S(ort)Q(uit),Selectone:"提示用户输入,A代表增加,D表示删除,S表示排序,Q代表推出,输入为ASD时分别提示“数据已经增加、删除、排序。”输入为Q时程序结束。①要求用ifelse语句判断,用breakcontinue控......
  • 打卡4.13
    #include<iostream>usingnamespacestd;classTime{public:      Time();      friendvoiddisplay();private:      inthour,minu,sec;};Time::Time(){     hour=11;      minu=11;      sec=11;}voiddisplay(){Tim......