zoukankan      html  css  js  c++  java
  • POJ

    //poj 2080
    //题目大意:给定天数,从2000年1月1日经过这些天后的 年 月 日 及 星期几
    //代码参照大牛的写的,本人还是处于菜鸟阶段,思路很好
    #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<math.h> #include<algorithm> using namespace std; #define N 1100 int IsLeap(int y) { return ((y%4==0&&y%100!=0) || (y%400==0)); } int main() { int n, ansy, ansm, ansd, answ; int tab[2][13]={{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; char s[7][10]={{"Saturday"}, {"Sunday"}, {"Monday"}, {"Tuesday"}, {"Wednesday"}, {"Thursday"}, {"Friday"}}; while(scanf("%d", &n), n!=-1) { ansy=2000; ansm=1; ansd=1; answ=n%7; while(n) { if(IsLeap(ansy)) { if(n>=366) { n-=366; ansy++; } else { if(n>=tab[IsLeap(ansy)][ansm]) { n-=tab[IsLeap(ansy)][ansm]; ansm++; } else { ansd+=n; n=0; } } } else { if(n>=365) { n-=365; ansy++; } else { if(n>=tab[IsLeap(ansy)][ansm]) { n-=tab[IsLeap(ansy)][ansm]; ansm++; } else { ansd+=n; n=0; } } } } printf("%d-%02d-%02d %s ", ansy, ansm, ansd, s[answ]); } return 0; }
  • 相关阅读:
    换盘符cd的用法
    matplotlib.pyplot 属性用法
    类 __init__的注意事项
    Python File(文件) 方法
    Spyder 快捷键
    python路径引用r的含义
    VBA+SQL transform pivot union联合查询的基础应用
    Box-Cox变换
    静态字段引用的对象为什么不会被GC回收
    编译hotspot8
  • 原文地址:https://www.cnblogs.com/9968jie/p/5417531.html
Copyright © 2011-2022 走看看