PDA

View Full Version : Programming HW



Simtoon
11-29-2010, 11:18 AM
Question One

Australians like to pay out our New Zealand cousins for their funny accent. To Australians. the Kiwi pronunciation of the letter i sounds more like our pronunciation of the letter u. The typical example we use is that fish and chips spoken in a Kiwi accent often sounds like fush and chups.

Your program should read in what John is trying to say, and replace every i with a u, and print out the result. For example:

Enter sentence: Fish and chips please.

Fush and chups please.

Here is another example:

Enter sentence: I'd like to go for a swim.

U'd luke to go for a swum.


WTF HOW DO I DO THAT IN PESUDOCODE!! HELP!!

Capricorn
11-29-2010, 11:20 AM
If character = i then character = u

?

Simtoon
11-29-2010, 11:22 AM
My teacher said use an array..

Frement
11-29-2010, 11:28 AM
char_array = split(string);
foreach (char_array as char) do
if (char == i) then
replace(char, u)
end
end
string = NULL
foreach (char_array as char) do
string += char
end
print string

In PHP:

$string = str_replace("i", "u", $string);
echo $string;

i luffs yeww
11-29-2010, 11:30 AM
#! /usr/bin/env python

import re

if __name__ == '__main__':
print re.sub('i', 'u', 'fish and chips please.')

Capricorn
11-29-2010, 11:38 AM
To be honest I do not know how close you can get to using Pesudocode with such a simple request... The real code is so quick and easy to write there really isn't a point to mocking up any code.

Simtoon
11-29-2010, 11:40 AM
I don't know this question is stupid.. i guess Frement gave me enough

Bad Boy JH
12-07-2010, 12:46 AM
I = 0
REPEAT
if String[i] == i then
string[i] = u
i = i + 1
until stringlength <= i

think of a string as an array of characters

i luffs yeww
12-07-2010, 06:42 AM
I = 0
REPEAT
if String[i] == i then
string[i] = u
i = i + 1
until stringlength <= i

think of a string as an array of characters

A string is an array of chars.. :p

Bad Boy JH
12-09-2010, 02:38 AM
yes, I know. However most people don't see it that way, view 3 as a decimal, its still tecnically a decimal... sorta

sadmemories20
03-15-2011, 06:41 AM
I don't know this question is stupid.. i guess Frement gave me enough

Sex
03-15-2011, 07:43 AM
In what language? This is super simple though man. Omg. Haha.

Zyt3x
03-15-2011, 03:09 PM
Gravedug by a spam bot :/

Sex
03-16-2011, 04:05 AM
I can't believe I didn't realize that. So sorry..lmao.