Make next C code more readable and professional: #include <stdio.h> #include <stdlib.h>…
- User
Make next C code more readable and professional: #include <stdio.h> #include <stdlib.h> #include <time.h>
struct tm easter_orthodox(int y) { int d = (19 * (y % 19) + 15) % 30, e = (2 * (y % 4) + 4 * (y % 7) - d + 34) % 7, x = d + e + 114; struct tm t = {0}; t.tm_year = y - 1900; t.tm_mon = x / 31 - 1; t.tm_mday = x % 31 + 1; t.tm_isdst = -1; int difference = y / 100 - y / 400 - 2; time_t s = mktime(&t) + difference * 86400; return *localtime(&s); }
int main(int c, char **v) { if(c!=2) return puts("Usage: ./easter_orthodox "),1; char *e; int y=(int)strtol(v[1],&e,10); if(*e) return puts("Year must be an integer."),1; struct tm d=easter_orthodox(y); printf("Date of Easter in the Russian Orthodox Church in %d: %02d.%02d.%04d\n",y,d.tm_mday,d.tm_mon+1,d.tm_year+1900); return 0; }
- Assistant