zoukankan      html  css  js  c++  java
  • 三天打渔,俩天晒网(C++实现)

    #include <iostream>
    using namespace std;
    int leap (int a)
    {
        if (a%4==0%a%100!=0||a%400==0)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
    int     number(int    year,int month,int day)
    {
        int    sum=0,i,j;
        int    a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
        int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};
        if (leap(year)==1)
        {for (i=0;i <month-1;i++)
            sum+=a[i];
        }
        else
        
            for (i=0;i<month-1;i++)
                sum+=b[i];    
            for (j=2011;j<year;j++)
                if (leap(j)==1)
                {
                    sum+=366;
                }
                else
                {
                    sum+=365;
                }
                sum+=day;
                return sum;
    }
    int main ()
    {
        int    year,month,day,n;
        cout<<"请输入年月日";
        cin>>year>>month >>day;
        n=number(year,month,day);
        if ((n%5)<4&&(n%5)>0)
        
            cout<<"打渔"<<year<<month<<day <<endl;
        else

            cout<<"晒网"<<year<<month<<day <<endl;

    }
  • 相关阅读:
    手机领域的各种角色介绍
    windows配置教程
    windows7安装教程(vmware)
    /etc/profile、~/.bash_profile、~/.bashrc和/etc/bashrc
    vmware自定义网段
    wps去除首字母自动大写
    Windows和Linux创建软链接和硬链接
    计算机的组成部件及其厂商
    windows开机锁定小键盘
    PL/SQL Developer安装教程
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/7237952.html
Copyright © 2011-2022 走看看