c语言 高手们 帮帮我吧 做一个日历 输入 年月 输出 该年该月的 日历

例子
请输入 年和月. (输入 >> 2008 4)
2010 4
[2010年 4月]

일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

#include<stdio.h>
#include<time.h>
main(){

//定义变量
struct tm t,*date;

time_t t_day;

int year,month;
int month_day;
int i,j;

struct tm *local;
time_t t_mow;
t_mow=time(NULL);
local=gmtime(&t_mow);

//输入年份和月份
printf("请输入年份:\n");
scanf("%d",&year);
printf("请输入月份:\n");
scanf("%d",&month );

if(month==2 ){
if(year%4==0 && year%100!=0)
month_day=29;
else
month_day=28;

}
else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
{
month_day=31;
}
else
month_day=30;

printf("当前时间是: ");
printf(asctime(local));
printf("\n\n");

printf("当月天数是:%d \n\n 日历\n",month_day); //输出当前天数

printf("一\t二\t三\t四\t五\t六\t日\t\n"); //日历的第一行,显示一二三四五六日

for (i=1;i<=month_day;i++)
{
t.tm_year=year-1900;
t.tm_mon=month-1;
t.tm_mday=i;
t.tm_hour=0;
t.tm_min=0;
t.tm_sec=0;
t.tm_isdst=0;
t_day=mktime(&t);

date=gmtime(&t_day);

if(i==1)
{
for(j=0;j<date->tm_wday;j++)
printf("\t");
}

if(date->tm_wday==6)
{
printf("%d\n",i);
}
else
printf("%d\t",i);

}
printf("\n\n",i);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-11-25
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int choose();
int shutdown();
void main()
{
system("color 0b");
char admin[100]="abc";
char secret[100]="123";
char nadmin[100]=;
char nsecret[100]=;
do
{
printf("\n");
printf("\n");
printf("\n");printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" 请输入用户名:");
gets(nadmin);
system("cls");
printf("\n");
printf("\n");
printf("\n");printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" 请输入密码:");
gets(nsecret);
system("cls");
}while(strcmp(admin,nadmin)!=0||strcmp(secret,nsecret)!=0);
system("cls");
printf("\n");
printf("\n");
printf("\n");printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" !!!!!!恭喜进入,请按任意贱继续!!!!!!");
getchar();
相似回答