Crappy Programs
Author |
Message |
Flikerator
|
Posted: Wed Nov 09, 2005 9:21 am Post subject: Crappy Programs |
|
|
All this program does is ask you for how many numbers you want to enter, then lets you enter them. Then it prints out all the numbers, excluding doubles.
Time to make: Roughly 5 mins
Rating: Boring
code: |
var num : int
put "Enter the upper value of the array: " ..
get num
var numbers : array 1 .. num of int
var stored : flexible array 1 .. 0 of int
var check : boolean := true
for i : 1 .. num
put "Enter the #", i, ": " ..
get numbers (i)
end for
for i : 1 .. num
for ii : 1 .. upper (stored)
if numbers (i) = stored (ii) then
check := false
end if
end for
if check = true then
put numbers (i)
new stored, upper (stored) + 1
stored (upper (stored)) := numbers (i)
end if
check := true
end for
|
Crappy Program 2
Total Time: roughly 5-10 mins
Rating: Boring + good (sort)
code: |
var numbers : array 1 .. 10 of int
var high : int
var aray : int := 0
for i : 1 .. 10 %Its ok to hardcode once in awhile :P
put "Enter #", i, " : " ..
get numbers (i)
end for
put ""
procedure highest
high := minint
for i : 1 .. 10
if numbers (i) > high then
aray := i
high := numbers (i)
end if
end for
end highest
for i : 1 .. 10
highest
put high
numbers (aray) := -1
end for
|
Crappy Program 3
Time: 5-10 mins
Rating: Amusing+Boring
code: |
%Just change sentence, doesnt have user input
var caps : string := "aeiou" %Holds all lower case letters
var sentence : string := "Hello how are you?!???!?!?!?!?" %The sentence
var lowercase : int := 0 %I dont like count, lolz
for i : 1 .. length (sentence) %Goes through all the letters of the sentence
if index (caps, sentence (i)) ~= 0 then %Checks the current letter if its lower case, and a vowel.
lowercase += 1 %Shows the current lower case vowel count
end if
end for
put "There are ", lowercase, " lower case vowels in the sentence;" %Displays how many lower case vowels there are
put sentence
|
Crappy Program 4
Time: 10-15 mins
Rating: Semi-Ok
code: |
var alpha : string := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
var sentence, lenword : string := ""
var words : int := 0
var len : int := 0
put "Enter a sentence ending with a period: " ..
get sentence : *
for i : 1 .. length (sentence) %Goes through all the chars in the sentence
if index (alpha, sentence (i)) = 0 then
words += 1
put lenword, ": ", len
len := 0
lenword := ""
else
len += 1
lenword += sentence (i)
end if
end for
put "There are ", words, " words in this sentence"
|
Crappy Program 5
Time: 10-15 mins
Rating: Very Boring
Additional: A "perfect number" is a number which all its factors added together equal the number (Not including it self). 6's factors are 1,2,3 Therefore 1+2+3 = 6 Therefore 6 is perfect.
code: |
var value : int := 0
for i : 2 .. 200000
for ii : 1 .. i - 1
if i mod ii = 0 then
value += ii
end if
end for
if value = i then
put i, " is a perfect number"
end if
value := 0
end for
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Wed Nov 09, 2005 9:43 am Post subject: (No subject) |
|
|
why are you posting "crappy programs"? |
|
|
|
|
|
GlobeTrotter
|
Posted: Wed Nov 09, 2005 4:43 pm Post subject: (No subject) |
|
|
Mine's faster:
code: |
fcn isPrime (n : int) : boolean
if n = 2 then
result true
end if
for i : 2 .. n - 1
if n mod i = 0 then
result false
end if
end for
result true
end isPrime
for n : 2 .. 13
if isPrime ((2 ** n) - 1) then
put ((2 ** n) - 1) * (2 ** (n - 1))
end if
end for
|
|
|
|
|
|
|
Flikerator
|
Posted: Fri Nov 11, 2005 5:16 pm Post subject: (No subject) |
|
|
Tony wrote: why are you posting "crappy programs"?
So people can see some turing source code? Boredum? lolz |
|
|
|
|
|
|
|