Click here to Skip to main content
15,306,245 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??
Updated 19-Nov-20 11:50am
Krunal Rohit 19-Feb-14 22:21pm
Homework ?
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
Dave Kreskowiak 19-Feb-14 23:21pm
Are you teaching this class or giving a presentation in it?

Will that code work? Barely. It's output all of the words, as one continuous string with no spaces between the words.
Krunal Rohit 19-Feb-14 22:33pm
You're a teacher doesn't mean that you can't have Home Task. :)
1Future 19-Feb-14 22:48pm
lol I am a student not a teacher .. but hey can you please have a look at my updated question and see if i'm doig it right?
Krunal Rohit 19-Feb-14 22:54pm
What have you done so far ? I mean by code.
Sergey Alexandrovich Kryukov 19-Feb-14 22:22pm
What is that, "pseudo code in C#", why? :-)
ZurdoDev 19-Feb-14 22:23pm
Where are you stuck?
Stuck you are where?
1Future 19-Feb-14 22:25pm
pretty much much from the beginning .. just the beginning is all I need .. so I can teach myself the rest
ZurdoDev 19-Feb-14 22:33pm
Well, I suppose there are lots of ways of doing it. You could split the values into a list of strings or array of strings and then reverse the order. You could likely even use LINQ. To keep it simple just do an array of strings.
1Future 19-Feb-14 22:49pm
Thank you. can you please have a look at my updated question and let me know if i'm doing it right?
ZurdoDev 20-Feb-14 6:58am
See Solution 1

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

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!


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

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.
ZurdoDev 20-Feb-14 6:58am
I say +5.

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