- 1
- 2
- 3
- 4
- 5
- 6
- 7
int array[100];
//~=//=~
for(i=0;i<100;++i)
{
if(array[i] != 0) continue;
break;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+66
int array[100];
//~=//=~
for(i=0;i<100;++i)
{
if(array[i] != 0) continue;
break;
}
Код ужасно упрощен, но смысл передан полностью. Как я такое написал хз.
+133
...
int
(mblen)(const char *s, size_t n)
{
if (s == (const char *)NULL) return 0; /* no state dependent codings */
if (n <= 0) return 0;
return (*s != 0);
}
...
int
mbtowc(wchar_t *pwc, register const char *s, size_t n)
{
if (s == (const char *)NULL) return 0;
if (n <= 0) return 0;
if (pwc) *pwc = *s;
return (*s != 0);
}
...
int
wctomb(char *s, wchar_t wchar)
{
if (!s) return 0; /* no state dependent codings */
*s = wchar;
return 1;
}
THE AMSTERDAM COMPILER KIT V6.0pre4
===================================
© 1987-2005 Vrije Universiteit, Amsterdam
2010-08-08
...
SUPPORT
=======
Languages:
ANSI C, Pascal, Modula 2. K&R is supported via the ANSI C compiler.
А где здесь, собсно, ANSI C?
+68
#include <iostream>
using namespace std;
unsigned ololo_div(unsigned what, unsigned by) {
unsigned cnt=0;
while( what>by ) {
what-=by;
cnt++;
}
if( what==0 ) cnt++;
return cnt;
}
int main() {
cout << ololo_div(10,0) << endl;
return 0;
}
"че там делить то)))"
http://codepad.org/nL06uX2s
+125
'q<->5.,q<->r<0>3.,q<T>r<0>3.,q<:>r<0>3.,q<:>r<0>3.,r<0>2.' 8!:2<.2014 3 2 3 30 46.034
Еще одни даты на J.
+143
// основная функция запуска
func main($script){
//устанавливаем значение переменной
$caption = "гыыы кальулятор";
//грузим иконку
$calc_icon= library_load_icon(library_load("shell32.dll"),307);
//создаем окошко))
$main_window=gui_window("TCalc",$caption,$_WS_SYSMENU+$_WS_VISIBLE+$_WS_CAPTION,$_CW_DESKTOPCENTER,$_CW_DESKTOPCENTER,200,100,$calc_icon,0,0,"WindowFunc");
gui_control($main_window,"button","ok",201,$_WS_CHILD+$_WS_VISIBLE+$_BS_DEFPUSHBUTTON+$_BS_FLAT,152,16,32,16);
gui_control($main_window,"edit","2+7",202,$_WS_CHILD+$_WS_VISIBLE,2,15,130,15);
gui_control($main_window,"static","Ready",203,$_WS_CHILD+$_WS_VISIBLE,16,36,130,16);
//иконка в трее...
tray_icon($main_window,$calc_icon,"ГАЛЬГУЛЯТОР",$_NIM_ADD);
tray_icon_show_balloon($main_window,"[$caption] -> Startup","Добро пожаловать в программу\nСоздано с неизвестным языком (название не придумал)",4);
idle(); //перевод программы в режим ожидания
}
func WindowFunc($hwnd,$msg,$param,$id){ //обработка сообщений виндоуса
if($msg==$_WM_CLOSE){ //если крестик нажали
tray_icon($main_window,$calc_icon,null,$_NIM_DELETE); //удаляем иконку
close(); //выходим
}
if($msg==$_WM_COMMAND){ //если нажали кнопку
if($id==201){ //click ok //определяем ID //math_compiler - производить математические операции
$res=math_compiler(gui_get($hwnd,202)); //gui_get - получить текст
if length($res)==0 { //gui_set - установить текст
$res="[ERROR]";
tray_icon_show_balloon($hwnd,"[$caption] -> Ашипка","Нивазможна\nправирить текст!",2);
}else{
tray_icon_show_balloon($hwnd,"[$caption] -> Result",gui_get($hwnd,202)." = $res",4);
}
gui_set($hwnd,203,$res);
}
}
}
Из желания многих увидеть интерпретатор сего кода, прошу вас! Вот же он -> http://coun.at.ua/stuff/1-1-0-117!
Знаю, что сейчас будет много отрицательных комментариев, но! Что мне добавить в язык? Говорите, дамы и господа!
+122
}:;(1,5#3)<@}."_1'--T:: ',.~":,.10000+<.6!:0''
Даты. Теперь на J.
−107
import System.Exit
import Graphics.UI.GLUT
import Control.Monad
import Control.Applicative
import Control.Arrow
import Control.Concurrent
import Graphics.Rendering.OpenGL
import Data.IORef
import Data.List
import Data.Maybe
initial = ((0,0),(0.005,-0.03),(0,0),([(-0.4,-0.9),(-0.4,-0.85),(0.4,-0.85),(0.4,-0.9),(-0.4,-0.9)],(0,0)),liftM2 (,) [-0.9,-0.7..0.9] [0.5,0.7,0.9])
ws = dzip [(-1,-1),(-1,1),(1,1),(1,-1)] ; r = 0.1 :: GLfloat
main = initialWindowSize $= Size 777 777 >> initialWindowPosition $= Position 100 100 >> initialDisplayMode $= [DoubleBuffered] >> createWindow "ursula" >>
newIORef initial >>= \ior -> keyboardMouseCallback $= Just (kbd ior) >> displayCallback $= dlay ior >> idleCallback $= Just (anime ior) >> mainLoop
dlay ior = clearColor $= Color4 1 1 1 1 >> clear [ColorBuffer] >> readIORef ior >>= drawDoxyq >> swapBuffers
kbd _ (Char 'q') Down _ _ = exitWith ExitSuccess
kbd s (Char x) Down _ _ = modifyIORef' s $ \(a,b,t,(d,e),cs) -> (a,b,t,(d,(if x == '[' then -0.05 else if x == ']' then 0.05 else fst e,0)),cs)
kbd _ _ _ _ _ = return ()
draw c = renderPrimitive c . mapM_ (vertex . uncurry Vertex2)
touch xy s xy' = guard ((xy ==== xy') <= r+r && (s .*. (xy.-.xy')) <= 0) >> Just (xy.-.xy')
drawDoxyq ((x,y),_,(t,_),(bd,_),cs) = currentColor $= Color4 0.3 0.4 0.8 0 >> mapM_ (mapM_ (draw LineLoop) . sta) cs >>
currentColor $= Color4 0.7 0.1 0.2 1 >> mapM_ (draw LineStrip) swa >> currentColor $= Color4 0 0 0 1 >> draw Polygon bd where
swa = [[(x,y),(x + r/1.8*cos (th+pi/4),y + r/1.8*sin (th+pi/4)),(x + r/1.2*cos th,y + r/1.2*sin th)] | th <- [t,t+pi/2..t+1.6*pi]]
sta (x,y) = [[(x,y+r/2),(x-r/2,y-r/2),(x+r/2,y-r/2)],[(x+r/2,y+r/2-0.03),(x-r/2,y+r/2-0.03),(x,y-r/2-0.03)]]
frame (xy,v,(tt,tr),(b,s),cs) = if snd xy <= r-0.99 || null cs then error "GAME OVER" else (xy.+.v',v',(tt+tr',tr'),(b',s'),cs') where
v' = listy v (\us -> rV (2*negv v .>. foldl1' (.+.) us + tr/11) $ negv v) $ mapMaybe (cutSect xy v) (ws ++ dzip b') ++ mapMaybe (touch xy v) cs
s' = 0.93 *. if any ((1<=) . (*signum (fst s)) . fst) b then negv s else s
b' = map (.+.s') b ; cs' = filter (isNothing . touch xy v) cs
tr' = if v .=. v' then tr else (v' .>. v)/19
listy d f x = if null x then d else f x
rV t (x,y) = (x*cos t - y*sin t,y*cos t + x*sin t)
anime ior = modifyIORef' ior frame >> threadDelay 30000 >> postRedisplay Nothing
cutSect xy s c@(u,v) = guard (xy ./ l <= r && w `oncut` c && (s .*. (xy.-.w)) <= 0) >> Just (xy.-.w) where
l = ln u (u.-.v) ; w = xy .-| l
oncut u (v,w) = 0 <= (u.-.v) .*. (w.-.u) && 0 <= (u.-.w) .*. (u.-.w) && ((u.-.w) .<>. (v.-.w)) # 0
ln xy w = (snd w,-fst w,w.<>.xy)
(x,y) .-| (a,b,c) = ((b^2*x - a*c - a*b*y)/(a^2 + b^2),-(b*c + a*b*x - a^2*y)/(a^2 + b^2))
p ./ ln = p ==== p .-| ln ; pop f (a,b) (c,d) = (f a c,f b d)
(.+.) = pop (+) ; (.-.) = pop (-) ; (.=.) = (uncurry (&&) .) . pop (#)
(*.) = tmap . (*) ; (.*.) = (uncurry (+) .) . pop (*)
(.<>.) = (uncurry (-) .) . (. uncurry (flip (,))) . pop (*) ; v .>. u = atan2 (v .<>. u) (v .*. u)
norm = sqrt . join (.*.) ; a ==== b = norm $ a.-.b ; negv = tmap negate
infix 4 #,*. ; infix 3 .+.,==== ; infix 8 .>.
x # y = abs (x-y) < 0.00001 ; tmap = join (***)
dzipWith = (<*> drop 1) . zipWith ; dzip = dzipWith (,)
Вся суть выразительности Haskell
+75
public static void main (String[] args) throws java.lang.Exception
{
int[] massivIntov = {1,2,3};
int elementInt = 2;
System.out.println(najtiElementVMassive(massivIntov,elementInt));
double[] massivDoublov = {1,2,3};
double elementDouble = 2;
System.out.println(najtiElementVMassive(massivDoublov,elementDouble));
String[] massivStringov = {"odin","dva","tri"};
String elementString = "dva";
System.out.println(najtiElementVMassive(massivStringov,elementString));
Integer[] massivIntegerov = {new Integer (1001),new Integer (1002),new Integer (1003)};
Integer elementInteger = new Integer (1002);
System.out.println(najtiElementVMassive(massivIntegerov,elementInteger));
// !!!
int[][] massivMassivIntov = {{1,2,3},{2,3,4},{3,4,5}};
int elementMassivIntov[] = {2,3,4};
System.out.println(najtiElementVMassive(massivMassivIntov,elementMassivIntov));
String[][][] massivMassivMassivStringov = {{{"a"},{"b"}},{{"c","d"}},{{"e","f"}}};
String[][] elementMassivMassivStringov = {{"c","d"}};
System.out.println(najtiElementVMassive(massivMassivMassivStringov,elementMassivMassivStringov));
String[][] oshibochniiElementMassivMassivStringov = {{"c","e","z"}};
System.out.println(najtiElementVMassive(massivMassivMassivStringov,oshibochniiElementMassivMassivStringov));
}
// -1 esli NotFound, snachala massiv potom element
static int najtiElementVMassive(Object massiv,Object element){
if(massiv instanceof int[]) {
for(int i=0; i<((int[])massiv).length; ++i)
if(((int[])massiv)[i]==(int)element)
return i;
} else if(massiv instanceof byte[]) {
for(int i=0; i<((byte[])massiv).length; ++i)
if(((byte[])massiv)[i]==(byte)element)
return i;
} else if(massiv instanceof boolean[]) {
for(int i=0; i<((boolean[])massiv).length; ++i)
if(((boolean[])massiv)[i]==(boolean)element)
return i;
} else if(massiv instanceof char[]) {
for(int i=0; i<((char[])massiv).length; ++i)
if(((char[])massiv)[i]==(char)element)
return i;
} else if(massiv instanceof float[]) {
for(int i=0; i<((float[])massiv).length; ++i)
if(((float[])massiv)[i]==(float)element)
return i;
} else if(massiv instanceof double[]) {
for(int i=0; i<((double[])massiv).length; ++i)
if(((double[])massiv)[i]==(double)element)
return i;
} else if(massiv instanceof short[]) {
for(int i=0; i<((short[])massiv).length; ++i)
if(((short[])massiv)[i]==(short)element)
return i;
} else if(massiv instanceof long[]) {
for(int i=0; i<((long[])massiv).length; ++i)
if(((long[])massiv)[i]==(long)element)
return i;
} else {
try {
for(int i=0; i<((Object[])massiv).length; ++i)
if(sravnitMassivi(((Object[])massiv)[i],element))
return i;
} catch (Exception e) {
for(int i=0; i<((Object[])massiv).length; ++i)
if((((Object[])massiv)[i]).equals(element))
return i;
}
}
return -1;
}
static boolean sravnitMassivi(Object massiv1,Object massiv2) {
try {
if((((Object[])massiv1)).length!=(((Object[])massiv1)).length) return false;
boolean ravni=true;
for(int i=0; i<(((Object[])massiv1)).length; ++i)
ravni=ravni&&sravnitMassivi((((Object[])massiv1))[i],(((Object[])massiv2))[i]);
return ravni;
} catch (Exception e) {
if(massiv1 instanceof int[]) {
return Arrays.equals((int[])massiv1,(int[])massiv2);
} else if(massiv1 instanceof byte[]) {
return Arrays.equals((byte[])massiv1,(byte[])massiv2);
} else if(massiv1 instanceof boolean[]) {
return Arrays.equals((boolean[])massiv1,(boolean[])massiv2);
} else if(massiv1 instanceof char[]) {
return Arrays.equals((char[])massiv1,(char[])massiv2);
} else if(massiv1 instanceof float[]) {
Поиск элемента в массиве
+91
while usedthrds<>cn do
begin
i:=i+1;
if manual=0 then
if i>ccpun then
break;
if manual=1 then
begin
gotoxy(1,stroka);read(cputime[i]);
end
else
begin
gotoxy(1,stroka);write(cputime[i]);
end;
realsumcpu:=cputime[i]+ost;
sumcpu:=cputime[i]+ost;
found:=0;
bin:=0;
min:=1;max:=cn;
search:
while (min<=max) and (found=0) do
begin
bin:=bin+1;
mid:=(min+max)div 2;
if sumcpu<sortedthrd[mid] then
max:=mid-1
else
if sumcpu>sortedthrd[mid] then
min:=mid+1
else
if used[mid]=1 then
begin
if mid<>cn then
begin
l:=1;
while sortedthrd[mid+l]=sortedthrd[mid] do
begin
if used[mid+l]<>1 then
begin
mdldmas:=sortedthrd[mid+l];
mdldnum:=sortednum[mid+l];
ost:=realsumcpu-mdldmas;
used[mid+l]:=1;
found:=1;break;
end;
l:=l+1;
if mid+l>cn then break;
end;
end;
if (mid<>1) and (found=0) then
begin
l:=1;
while sortedthrd[mid-l]=sortedthrd[mid] do
begin
if used[mid-l]<>1 then
begin
mdldmas:=sortedthrd[mid-l];
mdldnum:=sortednum[mid-l];
ost:=realsumcpu-mdldmas;
used[mid-l]:=1;
found:=1;break;
end;
l:=l+1;
if mid-l<1 then break;
end;
end;
break;
end
else
begin
mdldmas:=sortedthrd[mid];
mdldnum:=sortednum[mid];
used[mid]:=1;
ost:=realsumcpu-mdldmas;
found:=1;
break;
end;
end;
if (found=0) and (sumcpu>0) then
begin
sumcpu:=sumcpu-1;bin:=0;min:=1;max:=cn;
goto search;
end;
if found=0 then
ost:=realsumcpu
else
begin
gotoxy(6,stroka);write (realsumcpu);gotoxy (12,stroka);write (mdldmas);gotoxy(18,stroka);write(mdldnum);gotoxy(24,stroka);write(ost);gotoxy(30,stroka);write(bin);
stroka:=stroka+1;
end;
if found=1 then
begin
realsumcpu:=ost;
sumcpu:=ost;
found:=0;bin:=0;min:=1;max:=cn;
goto search;
end;
Как студенты пишут сортировку (полная версия https://gist.github.com/Karasiq/11184652)
−98
if value is False:
res = ~res
elif not value is True:
raise AnalyzeError("Invalid value {0}".format(condition.value))