Created
November 17, 2017 08:41
-
-
Save mehmeteminkartal/feb15732fe38278e189cd27c5d80f71a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.c | |
// timeChallange | |
// | |
// Created by Muhammet Mehmet Emin Kartal on 11/17/17. | |
// Copyright © 2017 Muhammet Mehmet Emin Kartal. All rights reserved. | |
// | |
#include <stdio.h> | |
#include <time.h> | |
const char* dow(int d) { | |
switch (d) { | |
case 0: | |
return "SUN"; | |
case 1: | |
return "MON"; | |
case 2: | |
return "TUE"; | |
case 3: | |
return "WED"; | |
case 4: | |
return "THU"; | |
case 5: | |
return "FRI"; | |
case 6: | |
return "SAT"; | |
} | |
return "None"; | |
} | |
const char* month(int d) { | |
switch (d) { | |
case 0: | |
return "JANUARY"; | |
case 1: | |
return "FEBRURAY"; | |
case 2: | |
return "MARCH"; | |
case 3: | |
return "APRIL"; | |
case 4: | |
return "MAY"; | |
case 5: | |
return "JUNE"; | |
case 6: | |
return "JULY"; | |
case 7: | |
return "AUGUST"; | |
case 8: | |
return "SEPTEMBER"; | |
case 9: | |
return "OCTOBER"; | |
case 10: | |
return "NOVEMBER"; | |
case 11: | |
return "DECEMBER"; | |
} | |
return "None"; | |
} | |
int main(int argc, const char * argv[]) { | |
int year = 2017; | |
printf("Yıl Girin: "); | |
scanf("%d" , &year); | |
printf("%d takvimi\n", year); | |
for (int days = 1; days <= 365; days++) { | |
struct tm time; | |
time.tm_isdst = -1; /* Allow mktime to determine DST setting. */ | |
time.tm_mon = 0; | |
time.tm_mday = days; | |
time.tm_year = year - 1900; | |
mktime(&time); | |
if (time.tm_mday == 1) { | |
printf("\n\n\t\t%s\n", month(time.tm_mon)); | |
} | |
if (time.tm_mday == 1) { | |
for (int i = 0; i < 7; i++) { | |
printf("%s\t", dow(i) ); | |
} | |
printf("\n"); | |
for (int i = 0; i < time.tm_wday; i++) { | |
printf("\t"); | |
} | |
} | |
printf("%d\t", time.tm_mday); | |
if (time.tm_wday == 6) { | |
printf("\n"); | |
} | |
} | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment