Good Bye 2015 A

Problem A:http://codeforces.com/problemset/problem/611/A

A. New Year and Days

题意:某人要在2016年收集糖果,有两种不同的收集方式,按week或month。x表示week的周x或月的x号,只有到每周或每月的x时才会收集一颗糖果,问:在给定的月或周条件内,2016年能收集多少颗糖果。

思路:我是用数组存好,其实也可以更简洁,周的话除了5,6,7是53个,其他都是52个;月的话1-29都是12(闰年),30是11,31是7;

#include <cstdio>  
#include <iostream>  
#include <string>  
using namespace std;  
int main(){  
    int a[10]={0,52,52,52,52,53,53,52};  
    int n,l;  
    string s1,s2;  
    cin>>n>>s1>>s2;  
    l=s2.length() ;  
    if(l==4)  
        printf("%d
",a[n]);  
    else if(l==5){  
        if(n<=29)  
            printf("12
");  
            if(n==30)  
            printf("11
");  
            if(n==31)  
            printf("7
");  
            }  
    return 0;  
}  
我会一直在
原文地址:https://www.cnblogs.com/zhien-aa/p/5167641.html