środa, 8 lutego 2017

Calendar 2017 (gcc)

#include <stdio.h>
#include <string.h>
char days[7][12]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
char months[12][12]={"January","February","March","April","Mai","June","July","August","September","Oktober","November","December"};
char days_in_year[365][12];
char months_in_year[365][12];
int nrday_in_year[365];

int main(int argc, char **argv)
{
    int i,j,day;
 j=0;
 for(i=0;i<365;i++)
 {
     strcpy(days_in_year[i],days[j]);
     j++;
     if(j==7)
      j=0;
 }

day=0; //january
do
{
 nrday_in_year[day]=day+1;
 strcpy(months_in_year[day],months[0]);
 ++day;
       
}while(day<31);
day=31;i=1; //february
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[1]);
    ++i;++day;
}while(day<59);
day=59;i=1; //march
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[2]);
    ++i;++day;
}while(day<90);
day=90;i=1; //april
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[3]);
    ++i;++day;
}while(day<120);
day=120;i=1; //mai
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[4]);
    ++i;++day;
}while(day<151);
day=151;i=1;//june
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[5]);
    ++i;++day;
}while(day<181);
day=181;i=1; //july
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[6]);
    ++i;++day;
}while(day<212);
day=212;i=1; //august
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[7]);
    ++i;++day;
}while(day<243);
day=243;i=1; //september
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[8]);
    ++i;++day;
}while(day<273);
day=273;i=1;//oktober
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[9]);
    ++i;++day;
}while(day<304);
day=304;i=1;//november
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[10]);
    ++i;++day;
}while(day<334);
day=334;i=1; //december
do
{
    nrday_in_year[day]=i;
    strcpy(months_in_year[day],months[11]);
    ++i;++day;
}while(day<365);



 for(i=0;i<365;i++)
 {
     printf("%s  -  %d    %s",months_in_year[i],nrday_in_year[i],days_in_year[i]);
     printf("\n");
 }   


   
    return 0;
}

Brak komentarzy:

Prześlij komentarz