#include "lol++.h" BTW( LOL++, implementation of LOLCODE-like language on top of C++ Written by Yusdi Saliman This is a sample code that implements bubble sort algorithm in LOL++. ) HOW DUZ I BUBBLE_SORT (UR LIST) LIEK DIZ BTW(Array is an extension from LOL++ which is not available in LOLCODE 1.2) I HAS A N ITZ LIST LENGTH; BTW(The way to make infinite loop in LOL++ is also a bit different) IM IN YR LOOP FOREVAR I HAS A SWAPPED ITZ FAIL; I HAS A COUNTER ITZ 1; N R DIFF OF N AN 1 _; IM IN YR LOOP UPPIN COUNTER TIL(BOTH SAEM COUNTER AN SUM OF N AN 1 MKAY _) BTW( If LIST[COUNTER] > LIST[COUNTER + 1] ) BOTH SAEM LIST[COUNTER] AN BIGGR OF LIST[COUNTER] AN SUM OF LIST[SUM OF COUNTER AN 1 _] AN 1 MKAY MKAY MKAY; O RLY YA RLY BTW( Swap! ) I HAS A TEMP ITZ LIST[COUNTER]; LIST[COUNTER] R LIST[SUM OF COUNTER AN 1 _]; LIST[SUM OF COUNTER AN 1 _] R TEMP; SWAPPED R WIN; OIC IM OUTTA YR LOOP BTW( If no swapping was done, we exit the loop ) NOT SWAPPED _; O RLY YA RLY GTFO; OIC IM OUTTA YR LOOP BTW( Return the list ) FOUND YR LIST; IF U SAY SO BTW(Unlike in LOLCODE, HAI in LOL++ indicates main function, not the start of the whole program) HAI VISIBLE "This is an implementation of bubble sort algorithm in LOL++." _; VISIBLE "See samples/lol_bubble_sort.cpp" _; BTW( Ask user to input the values ) I HAS A NUMBER_OF_VALUES; VISIBLE "How many values are there? " XD _; GIMMEH NUMBER_OF_VALUES _; BTW( GIMMEH will put a YARN into the variable, but we need a NUMBR ) NUMBER_OF_VALUES IS NOW A NUMBR _; BTW( Input each value ) I HAS A LIST; I HAS A COUNTER ITZ 1; IM IN YR LOOP UPPIN COUNTER TIL(BOTH SAEM COUNTER AN SUM OF NUMBER_OF_VALUES AN 1 MKAY _) VISIBLE "Value " & COUNTER & " :: " XD _; GIMMEH LIST[COUNTER] _; BTW(array index starts from 1) IM OUTTA YR LOOP BTW( Call the bubble sort function ) LIST R BUBBLE_SORT(LIST); BTW( Print the sorted list ) VISIBLE "Sorted list:: " XD _; COUNTER R 1; IM IN YR LOOP UPPIN COUNTER TIL(BOTH SAEM COUNTER AN SUM OF NUMBER_OF_VALUES AN 1 MKAY _) VISIBLE LIST[COUNTER] & " " XD _; IM OUTTA YR LOOP BTW( Print new line ) VISIBLE "" _; KTHXBYE