2006年10月26日 星期四

程設月曆 II

// month.cpp : 定義主控台應用程式的進入點。

//



#include "stdafx.h"

#include <stdlib.h>



int _tmain(int argc, _TCHAR* argv[])

{

int a,b,c,d,e,week;



printf("Enter the week\n");

scanf("%d",&week);

printf("\n");



d = 1;



for( a = 0 ; a <= ( week % 7 ) ; ++a , ++d) //印出第一行的空格//

printf(" ");



for( b = 1 ; b <= 12 ; ++b ){ //目前幾月//

if( b % 3 == 1 ){ //每3月停一次//

system("PAUSE");

}

for( e = 1 ; e <= 7 ; ++e , ++d ){ //月與月之間的空格//

printf(" ");

if( ( d % 7 ) == 0 ){ //顯示目前月份//

printf("\n");

printf("\n%d月\n" , b );

}

}

switch( b ){ //大月//

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12:

for( c = 1 ; c <= 31 ; ++c , ++d ){

printf("%3d",c);

if( ( d % 7 ) == 0 )

printf("\n");

}

break;

case 2: //2月//

for( c = 1 ; c <= 28 ; ++c , ++d ){

printf("%3d",c);

if( ( d % 7 ) == 0 )

printf("\n");

}

break;





case 4: //小月//

case 6:

case 9:

case 11:

for( c = 1 ; c <= 30 ; ++c , ++d ){

printf("%3d",c);

if( ( d % 7 ) == 0 )

printf("\n");

}

break;

}

}

printf("\n");

return 0;

}

1 則留言:

  1. 我還沒交到這個說

    你們還教的真快阿!



    但基本的架構都教過了



    我有看懂 爽



    ps 我程設還滿爛的= =

    回覆刪除