首页 > 其他分享 >POJ 2080 Calendar

POJ 2080 Calendar

时间:2023-05-26 15:01:05浏览次数:66  
标签:return int 31 30 years POJ year Calendar 2080


题目链接:http://poj.org/problem?id=2080

题目不是很难,也没什么说的,直接看代码吧:

#include<iostream>
#include<stdio.h>
using namespace std;
int year(int m)
{
	if(m % 4 == 0 && m % 100 != 0 || m % 400 == 0)
		return 1;
	else
		return 0;
}
int main()
{
	int n,i,j,years[2] = {365,366};
	int m1[2][12]={31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31};
	char week[7][10] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
	while(1)
	{
		scanf("%d",&n);
		int x = n;
		if(n == -1)	break;
		else
		{
			for(i = 2000;n >= years[year(i)];i++)
				n -= years[year(i)];
			for(j = 0;n >= m1[year(i)][j];j++)
				n -= m1[year(i)][j];
			printf("%d-%02d-%02d %s\n",i,j+1,n+1,week[x % 7]);
		}
	}
	return 0;
}

 

标签:return,int,31,30,years,POJ,year,Calendar,2080
From: https://blog.51cto.com/u_16131191/6356135

相关文章

  • 区分PO、VO、 BO、 DTO、 POJO
     分层领域模型规约:DO(DataObject):此结构与数据库表结构一一对应,通过DTO向上传输数据源对象。DTO(DataTransferObject):数据传输对象,Service或Manager向外传输的对象。BO(BusinessObject):业务对象,由Service层输出的封装业务逻辑的对象。AO(ApplicationObject):应用......
  • Tallest Cow(最高的牛)poj3263
    题目描述:FJ'sN(1≤N≤10,000)cowsconvenientlyindexed1..Narestandinginaline.Eachcowhasapositiveintegerheight(whichisabitofsecret).YouaretoldonlytheheightH(1≤H≤1,000,000)ofthetallestcowalongwiththeindexIoftha......
  • 超低功耗SUB 1G无线收发+32位 Soc芯片UM2080F32 无线集抄/测温/养老院人员定位
    UM2080F32是一款超低功耗32位IoTP:ARM®Cortex®-M0+,64KBFlash,16KBSRAM,Sub-1GHz射频收发器。工作于200MHz~960MHz范围内。UM2080F32内部还集成了CAN、12位SARADC、UART、SPI、QSPI、I2C等通用外围通讯接口,ADC、OPA、比较器等传感获取接口,以及LPTIMER、WDT等超低功耗......
  • poj-1519
    //132K0MSC++#include<cstdio>#include<cstring>usingnamespacestd;longlonggetDigitSum(longlongval){longlongdigitSum=0;if(val<10){returnval;}else{while(val){digitSum+=......
  • poj-2362
    //132K141MSC++withbeginSearchPos#include<cstdio>#include<cstring>#include<cstdlib>usingnamespacestd;intcmp(constvoid*a,constvoid*b)//降序{return*(longlong*)b-*(longlong*)a;}longlongfourEdgeLeng......
  • poj-2371
    //524K63MSC++#include<cstdio>#include<cstring>#include<cstdlib>intcmp(constvoid*a,constvoid*b){return*((int*)a)-*((int*)b);}usingnamespacestd;constintMAX=100001;intarray[MAX];intdataBaseSiz......
  • poj-1930
    //144K0MSC++#include<cstdio>#include<cstring>#include<cmath>intgcd(inta,intb){if(b==0){returna;}elseif(a>b){returngcd(b,a%b);}else{returngcd(a,b%a);}}/......
  • poj-1023
    //184K0MSC++#include<cstdio>#include<cstring>usingnamespacestd;charNP[65];//-1:n,1:pcharstr[80];chardigitUsed[80];charbinaryExpression[80];intcaseNum;intlength;longlongval;voidsolve(longlongval){l......
  • poj-1401
    //408K375MSG++#include<cstdio>#include<cstring>longlongget2FactorNum(longlongN){longlongres=0;while(N){res+=N/2;N/=2;}returnres;}longlongget5FactorNum(longlongN){long......
  • poj-2231
    //264K 47MS C++#include<cstdio>#include<cstring>#include<cstdlib>constintMAX=10005;longlongcowLocation[10005];intcmp(constvoid*a,constvoid*b){ return*((longlong*)a)-*((longlong*)b);}longlongcowNum;......