Re: [問題] C語言程式的問題~

看板TransCSI作者時間18年前 (2007/08/19 14:41), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
Problem-4 : 請輸入二整數值(其一代表某月份之天數, 其二代表該月份第一天之星期數), 再據以印出該月份之月曆圖型(若輸入30與5則印出: Sun Mon Tue Wed Thu Fri Sat --- --- --- --- --- --- --- 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 ============================================================= 假設星期天是0~~星期一是1~~星期六是6 #include<stdio.h> void calender(int n, int w){ int i,j=w; printf("Sun Mon Tue Wed Thu Fri Sat\n"); printf("--- --- --- --- --- --- ---\n"); for(i=0;i<w;i++) printf(" "); for(i=1;i<=n;i++){ if(j%7==0) { if(j!=0) printf("\n"); printf("%3d ",i); } else { printf("%3d ",i); } j++; } } main(){ int n,w; printf("Please input the days of the month and the first weekday: "); scanf("%d %d",&n,&w); printf("\n"); calender(n,w); printf("\n\n"); system("pause"); } ※ 編輯: mynewsky77 來自: 220.143.170.189 (08/20 18:12)
文章代碼(AID): #16n-OmOj (TransCSI)
文章代碼(AID): #16n-OmOj (TransCSI)