Submission

Status:
PPPPPPPPPPPPPPPPPPPP

Score: 100

User: foldnut

Problemset: ปฏิทินวันแม่

Language: c

Time: 0.001 second

Submitted On: 2024-09-25 15:55:54

#include<stdio.h>
#include<string.h>
#include<math.h>

void main(){
    int dayinyear[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int newyear;
    int month ,strday,r,sumdatebefore=0,motherday,dn;
    scanf("%d",&month);
    scanf("%d",&strday);
    for(int i =0;i<month-1;i++){
        sumdatebefore+=dayinyear[i];

    }
    newyear = strday - (sumdatebefore)%7;
    if(newyear<=0){
        newyear+=7;
    }
    //printf("%d ",newyear);
    motherday = newyear +(216%7);
    if(motherday>7){
        motherday-=7;
    }
    printf("%d",motherday);
    /*for(int i =0;i<month-2;i++){
        sumdatebefore+=dayinyear[i];

    }
    if((motherday - sumdatebefore)<0){
        r = sumdatebefore - motherday;
    }
    else{
        r = motherday - sumdatebefore;
    }
    if((strday-r)%7<=0){
        dn = (777777777776+strday-r)%7 +1;
    }
    else{
        dn = (strday-r)%7;
    }



    printf("%d",dn);


*/


}