RenHao

20140719HW4

Jul 19th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.     int i,j;
  9.     int Days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
  10.     int firstday = 3 ;
  11.     char *weekdays[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
  12.    
  13.     for(i=0;i<7;i++)
  14.         printf("%4s",*(weekdays+ i));
  15.     printf("\n");
  16.    
  17.     for(j=0;j<firstday;j++)
  18.             printf("    ");
  19.            
  20.     int k,flag =0;
  21.     for(i=0;i<12;i++)
  22.     {
  23.         for(j=1;j<=Days[i];j++)
  24.         {
  25.             printf(" %3d",j);
  26.             if(j%7==(7-(firstday+flag)%7)) //de
  27.             printf("\n");
  28.         }
  29.         printf("\n");
  30.         flag = flag + Days[i];
  31.         for(k=0;k<((firstday+flag)%7);k++) //de
  32.             printf("    ");
  33.        
  34.         //printf("\n");
  35.     }
  36.    
  37.    
  38.    
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment