【C】星期判断与日历打印

浏览: 230 发布日期: 2017-07-01 分类: c++
#include 

int run(int num);
int count(int y,int m,int d);
int check(int y,int m,int d);

main(){

//========================================================
	int iii=1;											//
	char ccc;											//
	while(iii=1){										//
//========================================================

//Definition
		int year,month,day,weekday,i,k=0,first;
		long sum;
		printf("Input the date:(yyyy-mm-dd)\n");
		scanf("%d-%d-%d",&year,&month,&day);
		
//Check
		if(check(year,month,day)){
			printf("Are you kidding me?!\n");
			break;
		}
//Print
		sum=count(year,month,day);
		first=(sum+1)%7;
		sum+=day;
		weekday = sum%7;
		printf("这天是");
		switch(weekday){
			case 0:	printf("星期天\n");break;
			case 1: printf("星期一\n");break;
			case 2:	printf("星期二\n");break;
			case 3:	printf("星期三\n");break;
			case 4: printf("星期四\n");break;
			case 5:	printf("星期五\n");break;
			case 6:	printf("星期六\n");break;
		}
		printf("该月日历:\n");
		printf("日\t一\t二\t三\t四\t五\t六\n");
		sum=0;
		for(i=0;i31)
		return 1;
	return 0;
}

以上就是【C】星期判断与日历打印的全文介绍,希望对您学习和使用c++编程开发有所帮助.
返回顶部