943,824 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2185
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 6th, 2007
0

Pls Help

Expand Post »
Given that input_time actually represents an integer value in seconds since the epoch - and has the value 0 at precisely "Thu Jan 1 00:00:00 1970", write a better implementation of this function.

1: unsigned long normalise(unsigned long input_time)
2: {
3:
4: bool finished;
5:
6: // This produces a formatted time string like:
7: // Thu_Nov_24_18:22:48_1986
8: string str_time = format_time( input_time );
9:
10: while( str_time.substr(1,3) != "Sun")
11: {
12: input_time -= 24*60*60;
13: str_time = format_time( input_time );
14: }
15:
16: while( str_time.substr(11,2) != "00" )
17: {
18: input_time -= 60*60;
19: str_time = format_time( input_time );
20: }
21:
22: while( str_time.substr(14,2) != "00")
23: {
24: str_time = format_time( input_time );
25: input_time -= 60;
26: }
27:
28: while( str_time.substr(17,2) != "00")
29: {
30: input_time -= 1;
31: str_time = format_time( input_time );
32: }
33:
34: return input_time;
35: }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hassan_kh is offline Offline
12 posts
since Sep 2007
Sep 6th, 2007
0

Re: Pls Help

Stop spamming with the same thing, please. All of your questions are pretty much impossible to answer as given, and it seems like you're trying to get free homework help.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Sep 6th, 2007
0

Pls Help

Using any programming language of your choice, implement algorithms to:


a) Reverse a string

b) Sort an array of Integers
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hassan_kh is offline Offline
12 posts
since Sep 2007
Sep 6th, 2007
0

Re: Pls Help

Is this a statement?
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Sep 6th, 2007
0

Re: Pls Help

I have not written the function. I was asked this question by a friend which he had got in an interview. These days I am trying to solve as many questions as possible as I learn more from it. If the question is not clear then I can re-send it with exact words.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hassan_kh is offline Offline
12 posts
since Sep 2007
Sep 6th, 2007
1

Re: Pls Help

Quote ...
These days I am trying to solve as many questions as possible as I learn more from it.
You're not solving anything by asking someone else do to it. And you're not learning anything either. _And_ you're spamming.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Sep 6th, 2007
0

Re: Pls Help

>> write a better implementation of this function.
You do it, we don't have the time. Of course if you would pay me $5,000.00 I will do it for you
Last edited by Ancient Dragon; Sep 6th, 2007 at 6:33 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Sep 6th, 2007
0

Re: Pls Help

as i described b4 ,I was asked this question by a friend which he had got in an interview.Thnx anyway.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hassan_kh is offline Offline
12 posts
since Sep 2007
Sep 6th, 2007
0

Re: Pls Help

Click to Expand / Collapse  Quote originally posted by hassan_kh ...
as i described b4 ,I was asked this question by a friend which he had got in an interview.Thnx anyway.
Not an excuse. You should follow forum rules regardless of who originally asked the question.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: help needed
Next Thread in C++ Forum Timeline: passing arrays / updating object arrays





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC