#include <bits/stdc++.h>
using namespace std;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

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

int main(){
	int y,n,month,dd;
	while(scanf("%d%d",&y,&n)!=EOF){
		if(prime(y)) day[2]=29;
		else day[2]=28;
		for(int i=1;i<=12;i++){
			if(n>day[i]) n-=day[i];
			else{
				dd=n;
				month=i;
				break;
			}
		}
		printf("%04d-%02d-%02d\n",y,month,dd);
	}	
	return 0;
}

下面是我自己的代码,在devc++上运行完全是正确的,不明白在oj的平台上怎么就不对了?

#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int r=0;
	int year,sum;
	scanf("%d%d",&year,&sum);
	int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//	while(scanf("%d%d",&year,&sum)!=EOF)
	while(cin>>year>>sum)
	{
	
	if(year%400==0||year%4==0&&year%100!=0)
	{
		day[2]=29;
	}
	int totalday[13]={0};
	for(int i=0;i<13;i++)
	{
		totalday[i]=totalday[i-1]+day[i];
	}
	
    for(r=0;r<13;r++)
	{
		if(sum<=totalday[r])
		break;
	}
	int dday=sum-totalday[r-1];

	printf("%d-%02d-%02d\n",year,r,dday);
}
	return 0;
}

再就是注意一下日期的标准输出格式

printf("%d-%02d-%02d\n",year,r,dday);