Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Day Of The Programmer
/* This code accepts an year as input from stdin and processes the very date of the Day of the Programmer in that year, aware of the fact that there was a shift from the Julian to Gregorian Calendar in the year 1918, in Russia (Day of The Programmer was founded here)*/ #include <assert.h> #include <ctype.h> #include <limits.h> #include <math.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> char* dayOfProgrammer(int year) { char dateLeap[11] = "12.09."; char dateNonLeap[11] = "13.09."; char* chyear = (char*)malloc(10 * sizeof(char)); char* date = (char*)malloc(15 * sizeof(char)); sprintf(chyear, "%d", year); if(year < 1918) { //julian calendar if(year%4 == 0) { date = strcat(dateLeap, chyear); } else { date = strcat(dateNonLeap, chyear); } } else if(year > 1918) { //gregorian calendar if(((year%4 == 0) && (year%100 != 0)) || (year%400 == 0)) { date = strcat(dateLeap, chyear); } else { date = strcat(dateNonLeap, chyear); } } else { //transitional year 1918 date = "26.09.1918"; } return date; } int main() { int* year; year = (int*)malloc(sizeof(int)); scanf("%d", year); printf("%s", dayOfProgrammer(*year)); return 0; }
run
|
edit
|
history
|
help
1
1.9 Time Function
1
child process
bit shift and mask
18BCE2182 MIDTERM PART-B CRITICAL
pseudo hw v.05
json string formatter
Largest and smallest
Pozdravljeni v mali soli C.
If then price calculation v1