APL/APL1.1/CM2/semaine.c
2022-01-25 14:25:17 +01:00

32 lines
662 B
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
char weekDays[7][9] = {
"dimanche",
"lundi",
"mardi",
"mercredi",
"jeudi",
"vendredi",
"samedi"
};
int main(void) {
int day, month, year;
printf("Donnez une date au format jj/mm/aa : ");
scanf("%d/%d/%d", &day, &month, &year);
year += 100; /*On assume que les dates données sont des années 2XXX*/
month -= 1;
struct tm partialDate = {};
partialDate.tm_mday = day;
partialDate.tm_mon = month;
partialDate.tm_year = year;
mktime(&partialDate);
printf("C'est un %s.\n", weekDays[partialDate.tm_wday]);
return EXIT_SUCCESS;
}