^English/MORE PROGRAM
Jump to navigation
Jump to search
Main page →→→→ ^English
Bubble sort
--- BUBBLE SORT --- Compare each list element two by two. If the former is larger than the latter of the two elements, the two elements are swap, just like bubbles float up one by one, the bigger number will go to the end of list. --- END --- Define a list, and read the list from user. Bubble sort the entire list, and output the result.
99x bottles of beers
Read a integer from user and then assign it to x, and push it into the stack. If x is larger than 0 then do these code forever: Print "%1 bottles of beers on the wall, \n%1 bottles of beers.\n". All %1 here will be replaced by x. Decreases x and then print "Take 1 down and pass it around, \n" If x is still larger than 0 then print "%1 bottles of beers on the wall.\n\n". All %1 here will be replaced by x. Otherwise, print "no bottles of beers on the wall.\n\n". End loop. Print "No more bottles of beers on the wall, \nno more bottles of beers.\n". Pop x from stack and restore it. Print "Go to the store and buy some more, \n%1 bottles of beers on the wall.\n\n". All %1 here will be raplaced by x. Throw x into the trash.
Sussy language interpreter
Input a string from user and throw it into the trash, and then output a Sinhala Letter Kantaja Naasikyaya.
Nope. interpreter
Input a string from user and throw it into the trash, and then output "Nope." without newline.
Do nothing
No operation.
Cat Program
If the user don't input nothing, then print the user input, otherwise break out.
Collatz function/sequence
Input an integer from user, and then assign it to x. Repeat these until x = 1: For every step, if x is an even, then assign x/2 to x, otherwise, assign 3x+1 to x. Print the value of x with a newline. End loop. Print "All done." without newline. Throw x into the trash.
Befunge 93 interpreter
Input a string from user, and assign it to SRC. For each character in SRC, there are: > → Move the pointer to right. < → Move the pointer to left. ^ → Move the pointer to up. v → Move the pointer to down. ? → Move the pointer randomly. _ → Pop a value; set direction to right if value=0, set to left otherwise. | → Pop a value; set direction to down if value=0, set to up otherwise. " → Read all character as this direction until next quote. : → Copy the top element from stack and throw it into the stack. \ → Swap the two top element of stack. $ → Pop the top element from stack and then throw it into the trash. + → Pop a and b, and then push a+b. - → Pop a and b, and then push b-a. * → Pop a and b, and then push a×b. / → Pop a and b, and then push b÷a. Partially, if a is 0, then raise an error: "What the f*ck did you let me do?!" % → Pop a and b, and then push mod(b, a). ! → Pop a, push 1 if a=0, push 0 otherwise. ` → Pop a and b, push 1 if b>a, push 0 otherwise. . → Pop a, and output a as an integer. , → Pop a, and output a as a Unicode Character. & → Input an integer from user and push it into stack. ~ → Innput an Unicode Character from user and push its Unicode into stack. (For example, an exclamation mark pushes 33.) 0123456789 → Push the value into the stack. # or a space mark → A placeholder. @ → End the program. p → A "put" call (a way to store a value for later use). Pop three values y, x and v, then change the character at the position (x,y) in the program to the character with ASCII value v. g → A "get" call (a way to retrieve data in storage). Pop two values y and x, then push the ASCII value of the character at that position in the program. If (x,y) is out of bounds, push 0.
Insertion sort
--- INSERTION SORT --- The process of direct insertion sorting is to insert each element into an ordered sequence in turn. All elements are divided into ordered and unordered areas, each time take the first element from the unordered area, compare it with each element in the ordered area from back to front, find the correct position, and insert the element into the correct position. The initial ordered area has only one element. Recall the situation of playing cards, when the cards are dealt according to the number of points and suits. This is how the insertion sort is used. --- END --- Define a list, and read the list from user. Insertion sort the entire list, and output the result.
Other
Coming soon, please come later.