C语言高手请进,急急急!!!

[复制链接]
查看11 | 回复3 | 2009-7-8 22:39:55 | 显示全部楼层 |阅读模式
#include
#include
#include
#include
void main()
{ do{
time_t *tp;
struct tm *tmptr;
int year,mon,matrix[7][6],m,n,max,i;
tp=(time_t *)malloc(sizeof(time_t));
tmptr=(struct tm *)malloc(sizeof(struct tm));
for(m=0;m2039))
{
printf ("Error!The year must between 1970 and 2039!\nInput the year:");
scanf("%d",&year);
}
printf("\nPlease input the month:");
scanf("%d",&mon);
while ((mon12))
{
printf ("\nError!The month must between 1 and 12!\n");
scanf("%d",&mon);
}
printf("%d-%d\n",year,mon);
tmptr->tm_sec=0;
tmptr->tm_min=0;
tmptr->tm_hour=0;
tmptr->tm_mday=1;
tmptr->tm_mon=mon-1;
tmptr->tm_year=year-1900;
*tp=mktime(tmptr);
tmptr=localtime(tp);
switch (mon){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
max=31;
break;
case 4: case 6: case 9: case 11:
max=30;
break;
case 2:
if((year%4==0&&year%100!=0)||(year%400==0))

max=29;
else

max=28;
break;
}
for(n=tmptr->tm_wday,i=1;n<7;n++)
matrix[0][n]=i++;
for(m=1;m<6;m++)
for(n=0;n<7&&i<=max;n++)
matrix[m][n]=i++;
printf(" SUN MON TUS WES THU FRI SAT \n");
for(m=0;m<6;m++){
for(n=0;n<7;n++)
if(matrix[m][n]!=0)

printf("%4d",matrix[m][n]);
else printf("
");
printf("\n");
}
printf("Do you want to use again?(y\\n)");
getchar();
}
while(getchar()=='y');
}
帮忙找下错误,并修改!

回复

使用道具 举报

千问 | 2009-7-8 22:39:55 | 显示全部楼层
不好意思我看到里面有用到结构体,可是没有结构体的定义,你的程序是不是不全呀?...
回复

使用道具 举报

千问 | 2009-7-8 22:39:55 | 显示全部楼层
这么多偷懒的人啊...
回复

使用道具 举报

千问 | 2009-7-8 22:39:55 | 显示全部楼层
是挺急的,lz补充一下问题吧,要做什么???...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行