[ create a new paste ] login | about

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

C, pasted on Jul 16:
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
unsigned how_many_days ( unsigned year, unsigned month, unsigned day)
{
const unsigned month12[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
unsigned days = month12[month-1] - day;

if ((year % 4 == 0 && year % 100) || year % 400 == 0);  // Кратный 4 и не кратный 100, или кратный 400


while ( month < 12 )
days += month12[month++];
return days;
}
int main ( )
{
setlocale(LC_ALL,"Rus");
unsigned year, month, day;
printf ("Введите день, месяц, год : ");
scanf ( "%d%d%d", &day, &month, &year);
printf ( "Осталось до конца года полных дней : %d, осталось до конца года полных месяцев : %d \n", how_many_days( year, month, day), 12-month);
system ( "pause");
return 0;
}


Output:
1
Disallowed system call: SYS_fork


Create a new paste based on this one


Comments: