Author |
Message |
aliveiswell

|
Posted: Mon Jan 12, 2004 5:45 pm Post subject: removes 4 letter words |
|
|
this was the final test for some of the people in my class. it's pretty simple but im proud of it. it removes all 4 letter words from a sentence.
code: |
var sentence : string
put "This program will remove all 4 letter words from a sentence."
loop
put ""
put "Please enter your sentence:"
get sentence : *
if length (sentence) > 80 then
put "That sentence is too long, please type another sentence."
else
if sentence = "exit" then
exit
end if
sentence := " " + sentence + " "
put sentence
var words : array 1 .. length (sentence) of string
for counter : 1 .. length (sentence)
words (counter) := sentence (counter)
end for
for counter : 2 .. length (sentence)
if counter = 2 and sentence (counter) = " " then
elsif counter = 3 and sentence (counter) = " " then
elsif counter = 4 and sentence (counter) = " " then
elsif counter = 5 and sentence (counter) = " " then
elsif sentence (counter) = " " and sentence (counter - 5) = " " and sentence (counter - 4) not= " " and sentence (counter - 3) not= " " and sentence (counter - 2) not= " " and
sentence (counter - 1) not= " " then
words (counter - 4) := "*"
words (counter - 3) := "*"
words (counter - 2) := "*"
words (counter - 1) := "*"
end if
end for
for counter : 1 .. length (sentence)
put words (counter) ..
end for
end if
end loop
put "You have exited..."
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Cervantes

|
Posted: Mon Jan 12, 2004 6:00 pm Post subject: (No subject) |
|
|
cool idea, kinda pointless interesting though  |
|
|
|
|
 |
Tony

|
Posted: Mon Jan 12, 2004 6:18 pm Post subject: (No subject) |
|
|
i remember doing something like that a long while back... I think the story behind the program was to sensor a certain 4 letter word, but since it can easily be modified, they desided to just sensor all 4 letter words Doesn't really solve the problem though  |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
shorthair

|
Posted: Fri Jan 23, 2004 10:21 am Post subject: (No subject) |
|
|
Ummmm your proram is good at what it does , , BUt you could probably mod that to censor out an array of words , so that it could actually be used for censor ship , but then you run into words spelt in spaces , G A * , and not even compsci has been able to * that out yet, id like to see a good censorship APP , it would actually be quite useful to me , as i do a bit of editing online |
|
|
|
|
 |
Tony

|
Posted: Fri Jan 23, 2004 3:07 pm Post subject: (No subject) |
|
|
well as long as an app is sensoring, there will always be a way around it
5uch 45 1337 5p34k, sensor that
heh, the only way I suppose would be to sensor everything that is not part of the dictionary of allowed words  |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
Maverick

|
Posted: Fri Jan 23, 2004 3:09 pm Post subject: (No subject) |
|
|
Y35 7H47 15 4 G00D 1D3A! |
|
|
|
|
 |
Andy
|
Posted: Fri Jan 23, 2004 5:24 pm Post subject: (No subject) |
|
|
u should've used index |
|
|
|
|
 |
sport

|
Posted: Fri Jan 23, 2004 7:12 pm Post subject: (No subject) |
|
|
If getting the sentence from a file you can use length command.
code: |
var fileno:int
var filename:string:="NAME"
var word:string
loop
get :fileno,word
if length(word) not =4 then
esle
put word
end if
end for
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
sport

|
Posted: Fri Jan 23, 2004 7:13 pm Post subject: (No subject) |
|
|
You will need a file called NAME in order for the program to work. |
|
|
|
|
 |
jonos

|
Posted: Mon Jan 26, 2004 10:51 am Post subject: (No subject) |
|
|
You could have just concatenated the different parts together at each new space, and not used an array. |
|
|
|
|
 |
|