Guest User

Untitled

a guest
Jun 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3. int main()
  4. {
  5. int month,day,week,c;
  6.  
  7. printf("請輸入月份及該月一日為星期幾(如七月四日請輸入:7 4)\n");
  8. scanf("%d",&month);
  9. scanf("%d",&week);
  10. if(month<1||month>12){
  11. printf("月份輸入錯誤\n");
  12. system("PAUSE");
  13. return 0;
  14. }
  15. if(week<1||week>7){
  16. printf("星期輸入錯誤");
  17. system("PAUSE");
  18. return 0;
  19. }
  20.  
  21.  
  22.  
  23. if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
  24. day = 31;
  25. }
  26. else if(month==4||month==6||month==9||month==11){
  27. day = 30;
  28. }
  29. else{
  30. day = 28;
  31. }
  32. printf("-----------------------------------------------------\n");
  33. printf("星期一\t星期二\t星期三\t星期四\t星期五\t星期六\t星期天\n");
  34. for(c=1;c<week;c++){
  35. printf("\t");
  36. }
  37. for(c=1+week;c<=day+week;c++){
  38. printf("%d\t",c-week);
  39. if(c%7==1){
  40. printf("\n");
  41. }
  42. }
  43. printf("\n");
  44. system("PAUSE");
  45. return 0;
  46. }
Add Comment
Please, Sign In to add comment