954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Pls Help

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: }

hassan_kh
Newbie Poster
12 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

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.

Hamrick
Posting Whiz
325 posts since Jun 2007
Reputation Points: 180
Solved Threads: 34
 
Hamrick
Posting Whiz
325 posts since Jun 2007
Reputation Points: 180
Solved Threads: 34
 

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


a) Reverse a string

b) Sort an array of Integers

hassan_kh
Newbie Poster
12 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

Is this a statement?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

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.

hassan_kh
Newbie Poster
12 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 
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.

Hamrick
Posting Whiz
325 posts since Jun 2007
Reputation Points: 180
Solved Threads: 34
 

>> 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 :)

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

as i described b4 ,I was asked this question by a friend which he had got in an interview.Thnx anyway.

hassan_kh
Newbie Poster
12 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 
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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

with all respect, don't think you can weasel by a few problems, get a degree and earn big digits!!!! this is software engineering, the most complex and diverse discipline in engineering. try the lottery for quick lute and easy answers.

mark busenitz
Newbie Poster
3 posts since Sep 2007
Reputation Points: 19
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You