首页 > 其他分享 >建民打卡日记4.16

建民打卡日记4.16

时间:2023-04-16 11:13:05浏览次数:36  
标签:totalDay 4.16 int 31 30 result year 打卡 建民

一、问题描述

某人从1990年一月一日开始“三天打鱼两天晒网”,问某天以后是打鱼还是晒网?

二、设计思路

1.输入日期

2.求1990年一月一日到该日期天数

3.对天数求余,根据余数输出“打鱼”或“晒网”

三、程序流程图

四、代码实现

#include <iostream>
using namespace std;

int runYear(int year) {
	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		return 1;
	else
		return 0;
}

int countDay(int y, int m, int d) {
	int perMonth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int totalDay = 0, year, i;
	for (year = 1990; year < y; year++) {
		if (runYear(year))
			totalDay = totalDay + 366;
		else
			totalDay = totalDay + 365;
	}
	if (runYear(y))
		perMonth[2]++;
	for (i = 1; i < m; i++) {
		totalDay += perMonth[i];
	}
	totalDay += d;
	return d;

}

int main() {
	int year, month, day;
	cin >> year >> month >> day;
	int totalDay;
	int result;
	totalDay = countDay(year, month, day);
	result = totalDay % 5;
	if (result > 0 && result < 4)
		printf("今天打鱼");
	else
		printf("今天晒网");
}

标签:totalDay,4.16,int,31,30,result,year,打卡,建民
From: https://www.cnblogs.com/cor0000/p/17321220.html

相关文章

  • 天天打卡一小时第四天
    1.问题描述实验1-4计算工资某公司员工的工资计算方法如下:一周内工作时间不超过40小时,按正常工作时间计酬;超出40小时的工作时间部分,按正常工作时间报酬的1.5倍计酬。员工按进公司时间分为新职工和老职工,进公司不少于5年的员工为老职工,5年以下的为新职工。新职工的正常工资为30元......
  • 2023.4.16
    1#include<iostream>2usingnamespacestd;3//设计圆类和点类,判断点和圆的关系4classPoint5{6public:7voidsetX(intx)8{9m_X=x;10}11intgetX()12{13returnm_X;14}15voidsetY(inty)......
  • 每日打卡
    #include<iostream>//剪刀石头布usingnamespacestd;intmain(){intN;cin>>N;char**a=newchar*[N];for(inti=0;i<N;i++){a[i]=newchar[2];}for(intk=0;k<N;k++){for(intj=0;j......
  • 每天打卡一小时 第六天 编译四部曲
    书接上回求特殊方程的正整数解 第一部曲自然语言第一步建立for循环 第二步数学计算进行选择 第二部曲流程图   第三部曲伪代码(代码)#include<bits/stdc++.h>usingnamespacestd;boolcheck(autox){ if(x-(int)x==0) { return1; } else { return......
  • 软工打卡
    1.classCar:publicVehicle{private:intzai,zhong;public:Car(stringNO,intz,intl):Vehicle(NO),zai(z),zhong(l){}intfee(){returnzai*8+zhong*2;}};classTruck:publicVehicle{private:intzhong;public:T......
  • 4.15打卡
    #include<iostream>#include<iomanip>usingnamespacestd;intmain(){charA,D,S,Q,ch;while(ch!='Q'){cout<<"Menu:A(dd)D(elete)S(ort)Q(uit),SelectOne:";cin>>ch;if(ch=='A&#......
  • 天天打卡一小时——2
    一.问题描述输入两个数字,比较两者之间的大小二.设计思路1.输入两个数2.比较二者的大小三.程序流程图  四.代码实现#include<iostream>usingnamespacestd;intmain(){intx,y;cout<<"Enterxandy:";cin>>x>>y;if(x!=y)if(x>y)cout......
  • 建民打卡日记4.15
    五本新书,借给a,b,c三人,每人借一本,共有多少种借书方案?二、设计思路1.从五个数中选取三个排列组合,确立循环范围2.建立循环穷举所有情况3.符合条件的情况输出三、程序流程图  四、代码实现#include<iostream>usingnamespacestd;intmain(){ inta,b,c,i=0;......
  • 打卡第四天
    比较两个数大小一、1.先定义两个变量xy,用于将输入值存与变量中2.运用if语句,如果两个数不相等,就比较两个数大小,若相等则直接输出x=y3.如果x>y,则输出结果,反之输出x<y二、 三、#include<iostream>usingnamespacestd;intmain(){ intx,y; cout<<"输入两个数的值"; cin>>x>......
  • 每天打卡一小时 第五天 编译四部曲
      第一部曲自然语言 建立双重循环求解选择语句输出 第二部曲流程图  第三部曲伪代码(代码)#include<stdio.h>intmain(){    intN;    scanf("%d",&N);    inta,b;    intf=0;    for(a=1;a*a<=N;a++)    {      ......