zoukankan      html  css  js  c++  java
  • USACO 1.1 Friday the Thirteenth

    /*
    ID: aznfy1
    PROG: friday
    LANG: C++
    */
    
    #include<stdio.h>
    #include<string.h>
    #include<iostream>
    #define clr(a,b); memset(a,b,sizeof(a));
    
    using namespace std;
    
    int dayofmonth[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int week[7];
    
    int isleap(int x)
    {
        if(x%4==0&&x%100!=0)
        return 1;
        else if(x%400==0)
        return 1;
        else
        return 0;
    
    }
    
    int main()
    {
        freopen("friday.in","r",stdin);
        freopen("friday.out","w",stdout);
    
        int n;
        while(cin>>n)
        {
            int t=0;
            clr(week,0);
            for(int i=1900;i<1900+n;i++)
            {
                if(isleap(i))
                dayofmonth[2]=29;
                else
                dayofmonth[2]=28;
                for(int j=1;j<=12;j++)
                {
                    week[(t+13)%7]++;
                    t+=dayofmonth[j];
                }
    
            }
            cout<<week[6]<<' '<<week[0]<<' ';
            for(int i=1;i<=4;i++)
            {
                cout<<week[i]<<' ';
            }
            cout<<week[5]<<endl;
        }
        return 0;
    }
    View Code
  • 相关阅读:
    模型
    smarty变量
    smarty变量调节器
    分页
    表单验证(注册)
    php数据库访问
    php面向对象 继承
    php 面向对象
    php正则数组
    php 函数
  • 原文地址:https://www.cnblogs.com/whatthefy/p/3080905.html
Copyright © 2011-2022 走看看