Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Any one good with pseudo code ?
Can you Write a short pseudo code routine to reverse the words in a string..
input string like “The project contained a few errors” into “errors few a contained project The"?

well this is what i have done,

string a = "The";
string b = "project";
string c = "contained";
string d = "a";
string e = "few";
string f ="errors";

print f, e, d, c, b, a

is this alright??
Posted
Updated 19-Nov-20 11:50am
v2
Comments
Krunal Rohit 19-Feb-14 22:21pm    
Homework ?
-KR
Dave Kreskowiak 19-Feb-14 22:28pm    
If you can't write this simple routine in pseudo code yourself, you shouldn't be teaching this class.

It's simple to do really. Think about how you would do this by hand.


1Future 19-Feb-14 22:31pm    
I know ...but please can you just sart me off.. thats all I need just a start and I will figure out the rest myself
Dave Kreskowiak 19-Feb-14 22:37pm    
You've got to be kidding me!

I already told you how to start off. Think about how you would do the task by hand, on paper.

Really, how are you going to answer questions on this stuff if you don't understand it completely yourself??
1Future 19-Feb-14 22:50pm    
can you please have a look at my update question and let me know if i'm doing it right? thank you

Psuedocode and C# together don't make sense.
You are probably ooking for C# code or an algorithm.
 
Share this answer
 
I would do it like that:

C#
string input = Console.ReadLine();

string[] words = input.Split(' ');

for(int i = words.length; i > 0; i--)// you could do words.length-1 or what I did on the next line
Console.Write(words[i-1] + " "); //important to remove 1 to match the string array offset!

Console.WriteLine();


Thats as basic as it can be, not a very elegant way to do it however.

By the way, there is no "print" in C# :)
 
Share this answer
 
v4
Comments
Dave Kreskowiak 19-Feb-14 23:20pm    
That was a really REALLY bad idea.

You just did the guys homework for him.
EveryNameIsTakenEvenThisOne 19-Feb-14 23:29pm    
I think not. If he tried to rely on others forever he will never become something near a programmer. However, he may be not intressted in that. The school system sucks, you are forced to learn stuff you will probably never need. - one can live quite well without stackoverflows / sleepless nights because of threadsyncronizing issues.

While I agree that we shouldnt spoonfeed people who are serious about learning, I dont care about those who dont want to. For me its just the fact that I´m the only stranger on the internet who answered his question without mocking him.

In the end every attempt you guys did, was a really REALLY bad idea. By the way, I didnt provide pseudocode :)

Regards!
Dave Kreskowiak 20-Feb-14 0:34am    
It is well known around here that we don't post code answers to homework questions for very good reason. Code is always turned in by the student as their own work. The end result is always a failing grade because the choice will usually have stuff in it that want covered in class, typing off the proof that it was not original work. Also choosing styles change from one assignment to then next, again a tip off.

In the end, all you did was help him get a failing grade.
EveryNameIsTakenEvenThisOne 19-Feb-14 23:36pm    
Thanks for the rating. Grown up much? :)
Dave Kreskowiak 20-Feb-14 0:35am    
Look who's talking.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900