problem link:
It is just a simple problem to solve.Just subtract hour from 11. if it is less than or equal 0 then add 12 with hour. and for min if it is not equal to zero than subtract min from 60. and for align use %02 specifier .
at first try yourself but if you can't then only see the code.
#include<stdio.h>
int main()
{
int h,m,i,j,t,h1,m1;
char ch;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%d %c %d",&h,&ch,&m);
h=11-h+(m==0);
if(m!=0)
m=60-m;
if(h<=0)
h+=12;
printf("%02d%c%02d\n",h,ch,m);
}
return 0;
}
No comments:
Post a Comment