[ create a new paste ] login | about

Link: http://codepad.org/s2VkCdVg    [ raw code | output | fork ]

C, pasted on May 19:
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define NUM_MONTHS 12

void MotherDay()
{
	time_t t = time(0);
	struct tm *Now = localtime(&t);

	int sunday = 0;

	const char * weekday[] = { "Chu Nhat", "Thu 2",
		"Thu 3", "Thu 4",
		"Thu 5", "Thu 6", "Thu 7" };
	int isLeapYear = 0;
	int daysInMonth[NUM_MONTHS] = {
		31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
	};

	int year = Now->tm_year + 1900;
	int month = Now->tm_mon + 1;
	int monthDay = Now->tm_mday;
	int dayOfWeek = Now->tm_wday;
	isLeapYear = (year % 4 == 0 || ((year % 100 == 0) && (year % 400 == 0)));

	if (isLeapYear)
	{
		daysInMonth[1] = 29;
	}
	printf("\nNgay hien tai la %d - %d - %d", year, month, monthDay);
	printf("\nNgay cuoi thang la %d - %d - %d", year, month, daysInMonth[Now->tm_mon]);


	printf("\nHom nay la %s", weekday[Now->tm_wday]);
}
	int main()
	{
		MotherDay();
		_getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments: