2个回答
展开全部
#include <stdio.h>
int numday[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}};
int IsLeap(int y)
{
return (y%400==0||y%4==0&&y%100!=0);
}
void print(int y,int m,int w)
{
int i,j,l;
printf("Calendar %d-%02d\n",y,m);
printf("---------------------\n");
printf("Su Mo Tu We Th Fr Sa \n");
printf("---------------------\n");
for (i=0;i<w;i++)
printf(" ");
if (IsLeap(y))
l=1;
else
l=0;
for (i=1;i<=numday[l][m-1];i++)
{
printf("%-3d",i);
w++;
if (w%7==0)
printf("\n");
}
if (w%7) printf("\n");
printf("---------------------\n");
}
int calday(int y,int m)
{
int i,j,d=0,w;
while (y>2007)
{
if (IsLeap(y)) d+=366;
else d+=365;
y--;
}
while (m>1)
{ --m;
d+=numday[0][m-1];
}
w=(d+1)%7;
return w;
}
int main()
{
int year,month,w;
int i,j,day=0;
scanf("%d%d",&year,&month);
if (year<2007) return 0;
w=calday(year,month);
print(year,month,w);
return 0;
}
你看这个可以吗?
int numday[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}};
int IsLeap(int y)
{
return (y%400==0||y%4==0&&y%100!=0);
}
void print(int y,int m,int w)
{
int i,j,l;
printf("Calendar %d-%02d\n",y,m);
printf("---------------------\n");
printf("Su Mo Tu We Th Fr Sa \n");
printf("---------------------\n");
for (i=0;i<w;i++)
printf(" ");
if (IsLeap(y))
l=1;
else
l=0;
for (i=1;i<=numday[l][m-1];i++)
{
printf("%-3d",i);
w++;
if (w%7==0)
printf("\n");
}
if (w%7) printf("\n");
printf("---------------------\n");
}
int calday(int y,int m)
{
int i,j,d=0,w;
while (y>2007)
{
if (IsLeap(y)) d+=366;
else d+=365;
y--;
}
while (m>1)
{ --m;
d+=numday[0][m-1];
}
w=(d+1)%7;
return w;
}
int main()
{
int year,month,w;
int i,j,day=0;
scanf("%d%d",&year,&month);
if (year<2007) return 0;
w=calday(year,month);
print(year,month,w);
return 0;
}
你看这个可以吗?
追问
我试下
追答
能用就好,很高兴能帮到你
展开全部
代码如下:
#include <stdio.h> int numday[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}}; int IsLeap(int y) { return (y%400==0||y%4==0&&y%100!=0); } void print(int y,int m,int w) { int i,j,l; printf("Calendar %d-%02d\n",y,m); printf("---------------------\n"); printf("Su Mo Tu We Th Fr Sa \n"); printf("---------------------\n"); for (i=0;i<w;i++) printf(" "); if (IsLeap(y)) l=1; else l=0; for (i=1;i<=numday[l][m-1];i++) { printf("%-3d",i); w++; if (w%7==0) printf("\n"); } if (w%7) printf("\n"); printf("---------------------\n"); } int calday(int y,int m) { int i,j,d=0,w; while (y>2007) { if (IsLeap(y)) d+=366; else d+=365; y--; } while (m>1) { --m; d+=numday[0][m-1]; } w=(d+1)%7; return w; } int main() { int year,month,w; int i,j,day=0; scanf("%d%d",&year,&month); if (year<2007) return 0; w=calday(year,month); print(year,month,w); return 0; }
#include <stdio.h> int numday[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}}; int IsLeap(int y) { return (y%400==0||y%4==0&&y%100!=0); } void print(int y,int m,int w) { int i,j,l; printf("Calendar %d-%02d\n",y,m); printf("---------------------\n"); printf("Su Mo Tu We Th Fr Sa \n"); printf("---------------------\n"); for (i=0;i<w;i++) printf(" "); if (IsLeap(y)) l=1; else l=0; for (i=1;i<=numday[l][m-1];i++) { printf("%-3d",i); w++; if (w%7==0) printf("\n"); } if (w%7) printf("\n"); printf("---------------------\n"); } int calday(int y,int m) { int i,j,d=0,w; while (y>2007) { if (IsLeap(y)) d+=366; else d+=365; y--; } while (m>1) { --m; d+=numday[0][m-1]; } w=(d+1)%7; return w; } int main() { int year,month,w; int i,j,day=0; scanf("%d%d",&year,&month); if (year<2007) return 0; w=calday(year,month); print(year,month,w); return 0; }
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询