示例#1
0
void print_month(int month, int year)
{
	int ymo = year - 1, i, days=0, dow = 0, start = 0;
	int month_length(int n, int year);
	char *month_name(int n);
	
	// Find the number of days in the year before the first day of the month
	for (i = 1; i < month; i++){
		days += month_length(i, year);
	}
	// Find the day of week which the first of the month lands on
	dow = (1 + days + 365*ymo + ymo/4 - ymo/100 + ymo/400) % 7;
	
	// Print the header information
	printf("    %s, %d\n", month_name(month), year);
	printf("  S  M  T  W  R  F  S\n");
	
	// Print spaces until the right day of week
	for (i = 0; i < dow; i++)
		printf("   ");
	
	// Print the lines for each week, putting a new line every seven entries
	for (i = 0; i < month_length(month, year); i++, dow++){
		if ((dow % 7) == 0 && start != 0)
			printf("\n");
		start++;
		(i > 8) ? printf(" %d", i + 1) : printf("  %d", i + 1);
	}
	printf("\n");

}
示例#2
0
文件: 5-9.c 项目: devilTian/Fragment
int main() {
    int t = day_of_year(2016, 2, 11);
    int *pmonth, *pday;
    month_day(2016, t, &pmonth, &pday);
    printf("day is [%d]\n", t);
    printf("month[%d] and day[%d]\n",pmonth, pday);
    printf("%s\n", month_name(2));
    return 1;
}
/* ****************************** Main ****************************** */
int main(int argc, char *argv[])
{
    int month, day;

    month_day(1987, 50, &month, &day);
    printf("%s,%d\n", month_name(month), day);
    printf("%d\n", day_of_year(2001, 12, 31));

    return 0;
}
int main()
{
    int date;
    int day,month,year;
    
    scanf("%i",&date);
        
    year = (int)floor(date/10000);
    month = (int)floor( (date%10000)/100 );
    day = date%100;
          
    if(date_check(year,month,day) == -1)
       printf("Invalid entry\n");                                       
    else if(day ==2)
       printf("%s %dnd %d\n",month_name(month),day,year);
    else   
       printf("%s %d%s %d\n",month_name(month),day,(day==1||day==31)?"st":"th",year);
    
    return 0;
}
示例#5
0
/* main program */
int main( int argc, char *argv[] ) {
  int year, day, month, yearday;
  printf( "test day_of_year, input a year, month and day of month:\n" );
  scanf( "%d %d %d", &year, &month, &day );
  printf( "the day of year is: %d\n", day_of_year( year, month, day ) );
  printf( "testing month_day, input a year and day of year:\n" );
  scanf( "%d %d", &year, &yearday );
  month_day( year, yearday, &month, &day );
  printf( "the month is %d, day of month is %d\n", month, day );
  printf( "the name of month is: '%s'\n", month_name( month ) );
  return 0;
}
示例#6
0
int main(void)
{
	int n;
//	printf("Input a month number.\n");
//	scanf("%d", &n);
	
	for(n=0;n<14;n++)
	
	printf("The month name is %s.\n", month_name(n));

	return 0;
}
示例#7
0
main()
{
  printf("Year day for 1/1/2000: %d\n", year_day(2000, 1, 1));
  printf("Year day for 12/31/2001: %d\n", year_day(2001, 12, 31));
  printf("Year day for 11/14/2004: %d\n", year_day(2004, 11, 14));
  printf("Year day for 12/31/2004: %d\n", year_day(2004, 12, 31));

  int day, month;
  month_day(2004, 365, &month, &day);
  printf("month_day(2004, 365) --> %d / %d\n", month, day);
  printf("month %d --> %s\n", month, month_name(month));

}// end main
示例#8
0
int output_table(employ_t * company, int workers_n)
{
    int i, j;
    char name[35];
    printf("Name%16c", ' ');
    for (i = 0; i < 12; i++)
        printf("%9s", month_name(i));
    printf("\n");
    for (i = 0; i < workers_n; i++) {
        sprintf(name, "%s %c. %c.", company[i].names[1],
                *(company[i].names[0]), *(company[i].names[2]));
        printf("%-20s", name);
        for (j = 0; j < 12; j++)
            printf("%9d", company[i].salary[j]);
    }
    return 1;
}
示例#9
0
int input(employ_t * company)
{
    int i = 0, j = 0;
    for (i = 0; i < MAX_STUDENTS_NUMBER; i++) {
        printf("Provide First Name. To end input press enter:\n");
        fgets_c(company[i].names[0], NAME_SIZE, stdin);
        if (*company[i].names[0] == '\n')
            break;
        printf("Last Name:\n");
        fgets_c(company[i].names[1], NAME_SIZE, stdin);
        printf("Patronymic:\n");
        fgets_c(company[i].names[2], NAME_SIZE, stdin);
        for (j = 0; j < 12; j++) {
            printf("Provide salary for %s\n", month_name(j));
            while (get_posint(&company[i].salary[j]) == -1)
                printf("Please print positive numbers.\n");
        }
    }
    return i;
}
示例#10
0
void main()
{
 restart:
 clrscr();
 cout<<"Enter year : ";
 unsigned int y,m;
 cin>>y;
 int x;
 x=step1(y);
 int month[14][12]= {{1,4,4,7,2,5,7,3,6,1,4,6},{2,5,5,1,3,6,1,4,7,2,5,7},{3,6,6,2,4,7,2,5,1,3,6,1},{4,7,7,3,5,1,3,6,2,4,7,2},{5,1,1,4,6,2,4,7,3,5,1,3},{6,2,2,5,7,3,5,1,4,6,2,4},{7,3,3,6,1,4,6,2,5,7,3,5},{1,4,5,1,3,6,1,4,7,2,5,7},{2,5,6,2,4,7,2,5,1,3,6,1},{3,6,7,3,5,1,3,6,2,4,7,2},{4,7,1,4,6,2,4,7,3,5,1,3},{5,1,2,5,7,3,5,1,4,6,2,4},{6,2,3,6,1,4,6,2,5,7,3,5},{7,3,4,7,2,5,7,3,6,1,4,6}};
 cout<<"Enter month (1 - 12) : ";
 month_input:
 cin>>m;
 if(m<1 || m>12)
 {
  cout<<"Enter a valid month (1 - 12) : ";
  goto month_input;
 }
 cout<<"		";month_name(m);
 cout<<' '<<y<<"\nMon	Tue	Wed	Thu	Fri	Sat	Sun";
 int j=month[x-1][m-1], days=no_days(m,y);
 for (int i=0; i<j-1; i++)
  cout<<'	';
 for(i=1; i<=days; i++)
 {
  cout<<i<<'	';
  if(j==7)
  {
	cout<<' ';
	j=1;
  }
  else
	j++;
 }
 cout<<"Try for another month? (y/n) : ";
 char ch;
 cin>>ch;
 if(ch=='y' || ch=='Y')
  goto restart;
}
示例#11
0
int main()
{
  int m = 10;
  printf("%s\n", month_name(m));
  return 0;
}
示例#12
0
int main(int argc, char **argv)  
{  
        printf("month 2 is %s \n", month_name(2));  
        return 0;  
}
int main ()
{
  printf("Month: %s\n", month_name(-1));
  printf("Month: %s\n", month_name(14));
  return(0);
}
示例#14
0
main() {
	int n = 12323;
	char *month;
	month = month_name(n);
	printf("%s\n", month);
}
示例#15
0
main()
{
	printf("%s\n",month_name(3));
	return 0;
}