Library Fine
Question :-
https://www.hackerrank.com/challenges/library-fine/problem
Solution in C language :-
#include<stdio.h>
int main(){
int d1,d2,m1,m2,y1,y2;
scanf("%d%d%d%d%d%d",&d1,&m1,&y1,&d2,&m2,&y2);
if(d1!=d2 || m1!=m2 || y1!=y2)
{if(y1>=y2){
if(m1>m2 && y1==y2){
printf("%d",500*(m1-m2));
}
if(m1<m2 && y1==y2){
printf("0");
}
else if(d1>d2 && m1==m2 && y1==y2){
printf("%d",15*(d1-d2));
}
else if(d1<d2 && m1==m2 && y1==y2){
printf("0");
}
else if(y1>y2){
printf("10000");
}
}
else if(y1<y2){
printf("0");
}}
else if((d1==d2 && m1==m2 && y1==y2))
printf("0");
return 0;
}
Comments
Post a Comment