首页 > 其他 > 详细

SGU115 水题 Too Easy

时间:2014-01-29 02:14:05      阅读:371      评论:0      收藏:0      [点我收藏+]

Problem: Write a program that finds the name of the day of the week for any date in 2001(Monday – number 1, … , Sunday – number 7).

Solution: "Impossible" is important...

#include <stdio.h>
#include <iostream>
using namespace std;
int p[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int n,m,sum;
int main() {
    while (~scanf("%d%d",&n,&m)) {
          sum = 0;
          if (m<1 || m>12 || n<1 || n>p[m]) {
             printf("Impossible\n");
             continue;
          }
          int tt = 1;
          while (tt<m) {
                sum += p[tt];
                tt++;
          }
          sum += n;
          sum %= 7;
          if (sum==0) sum = 7;
          printf("%d\n",sum);
    }
    return 0;
}


SGU115 水题 Too Easy

原文:http://blog.csdn.net/lotus_land/article/details/18848655

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!