Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<stdlib.h>
- int main()
- {
- int month,day,week,c;
- printf("請輸入月份及該月一日為星期幾(如七月四日請輸入:7 4)\n");
- scanf("%d",&month);
- scanf("%d",&week);
- if(month<1||month>12){
- printf("月份輸入錯誤\n");
- system("PAUSE");
- return 0;
- }
- if(week<1||week>7){
- printf("星期輸入錯誤");
- system("PAUSE");
- return 0;
- }
- if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
- day = 31;
- }
- else if(month==4||month==6||month==9||month==11){
- day = 30;
- }
- else{
- day = 28;
- }
- printf("-----------------------------------------------------\n");
- printf("星期一\t星期二\t星期三\t星期四\t星期五\t星期六\t星期天\n");
- for(c=1;c<week;c++){
- printf("\t");
- }
- for(c=1+week;c<=day+week;c++){
- printf("%d\t",c-week);
- if(c%7==1){
- printf("\n");
- }
- }
- printf("\n");
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment