Latest Updates ☛
  • Graphs: Introduction of graphs and types of graphs
  • SPOJ : Geeky solves geeky solution
  • Solution Code : Pass the time problem on SPOJ.
  • Find the minimum shortest path solution in c language ! !

Saturday, September 7, 2013

Stan complete your homework in time and tell me total time solution



Question :
Stan is a sincere kid. His dad asked him to complete his home work and tell him the total time in which he completed his work. Stan noted down the no. of seconds in which he completed his home work, but he wants to tell the time to his dad in the following format:
Hours Minutes Seconds
Can you do this for him?

Inputs
First line will contain "T" the no. of test cases. Each of the next "T" lines will contain an integer "A" denoting the no. of seconds in which he completed his task.

Outputs :
For each test case "T" print the time in the format "Hours Minutes Seconds" in a single line.

Constraints
1 <= T <= 10^4,0 <= A <= 10^9






Level :Starter,Cakewalk

Solution to the Problem :


#include<stdio.h>

void perform(int k)
{
     int x,y,z;
     x=k/3600;
     k=k%3600;
     y=k/60;
     k=k%60;
     z=k;
     printf("%d %d %d\n",x,y,z);
}



main()
{
      int t;
      scanf("%d",&t);
      while(t--)
      {
                int k;
                scanf("%d",&k);
                perform(k);
      }
}




Privacy Policy | Disclaimer | Terms of Service

Copyright © 2013, Code Author. Powered by Blogger.