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

    # include <stdio.h>

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


    main ()
    {
       FILE 
    *in=fopen("friday.in","r");
       FILE 
    *out=fopen("friday.out","w");
         
       
       
    int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
       
    int week[8]={0};
       
    int year,i,j,data=13;
       
       
       fscanf (
    in,"%d",&year);
       year
    +=1900;
       
    for (i=1900;i<year;i++)
       {
          
    for (j=1;j<=12;j++)
          {
             data
    =data%7;
             
    if (data==0) week[7]++;
             
    else week[data]++;
             
             data
    +=month[j];
             
    if ((j==2)&&(leap(i)==1))
                data
    ++;
             
             }
          }
       
       fprintf (
    out,"%d %d",week[6],week[7]);
       
    for (i=1;i<=5;i++)
          fprintf (
    out," %d",week[i]);
       fprintf (
    out,"\n");
       fclose (
    in);
       fclose (
    out);
       exit(
    0);
    }
  • 相关阅读:
    uva 1605 building for UN ——yhx
    uva 120 stacks of flapjacks ——yhx
    uva133-S.B.S.
    Uva10082 WERTYU -S.B.S.
    Quicksum-S.B.S.
    NOIP2014提高组 DAY1 -SilverN
    NOIP2013普及组 -SilverN
    uva 1354 Mobile Computing ——yhx
    UVa 11292 Dragon of Loowater
    UVa 839 Not so Mobile
  • 原文地址:https://www.cnblogs.com/vistach/p/1536265.html
Copyright © 2011-2022 走看看