Do you know the FB page named Sarcasm ??
I think there are very few who don't know that page...
Recently it posted some photo that shows the time in words instead .
Have a look at this image...here it is...
Here is the link of that post: Facebook
Question:
Code the code :
Input:
8 12:15 12:20 12:30 12:40 12:45 12:50 12:55 12:60
Output:
QUARTER PAST TWELVE TWENTY PAST TWELVE HALF PAST TWELVE TWENTY MINUTES TO ONE QUARTER TO ONE TEN MINUTES TO ONE FIVE MINUTES TO ONE ONE OCLOCK
Code:
#include<stdio.h>
int func()
{
char a[21][10]={
{'H','A','L','F'},{'T','E','N'},
{'Q','U','A','R','T','E','R'},{'T','W','E','N','T','Y'},
{'F','I','V','E'},{'M','I','N','U','T','E','S'},{'T','O'},
{'P','A','S','T'},{'O','N','E'},{'T','W','O'},
{'T','H','R','E','E'},{'F','O','U','R'},{'F','I','V','E'},
{'S','I','X'},{'S','E','V','E','N'},{'E','I','G','H','T'},
{'N','I','N','E'},{'T','E','N'},{'E','L','E','V','E','N'},
{'T','W','E','L','V','E'},{'O','C','L','O','C','K'}
};
int i;
int p[21];
for(i=0;i<21;i++)
{
p[i]=0;
}
for(i=0;i<21;i++)
{
//printf("%s\n",a[i]);
}
int hr,m;
char waste;
scanf("%d",&hr);
scanf("%c",&waste);
scanf("%d",&m);
//12:60
if(m==60)
{
m=0;
hr=hr+1;
if(hr==13)
{
hr=1;
}
}
int count=0;
if(m<=38)
{
p[7]=1;// past
p[hr+7]=1;//for hours hand
if((m>=29)&&(m<=38))
{
p[0]=1;
}
else if((m>=19)&&(m<=28))
{
p[3]=1;
}
else if((m>=14)&&(m<=18))
{
p[2]=1;
}
else if((m>=9)&&(m<=13))
{
p[1]=1;
}
else if((m<=8)&&(m>=3))
{
p[4]=1;
}
else
{
p[20]=1;
p[7]=0;// remove past
}
}
else //m>=39
{
p[6]=1;//to
hr=(hr+1);
if(hr==13)
{
hr=1;
}
p[hr+7]=1;
if((m>=39)&&(m<=42))
{
p[3]=1;
p[5]=1;
}
else if((m>=43)&&(m<=48))
{
p[2]=1;
}
else if((m>=49)&&(m<=53))
{
p[1]=1;
p[5]=1;
}
else if((m>=54)&&(m<=59))
{
p[4]=1;
p[5]=1;
}
}
for(i=0;i<21;i++)
{
if(p[i])
{
printf("%s ",a[i]);
}
}
printf("\n");
}
int main()
{
int i=1;
while(i<9)
{
func();
i++;
}
return 0;
}

No comments:
Post a Comment