1. Си / Говнокод #15828

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    ...
    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?

    Pythoner, 23 Апреля 2014

    Комментарии (2)
  2. SQL / Говнокод #15827

    −3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    <?php
    // DB
    $DB_HOSTNAME = "localhost";
    $DB_USERNAME = "********";
    $DB_PASSWORD = "********";
    $DB_DATABASE = "vladbl0m_eshop";
    
    // Create connection
     $con=mysqli_connect($DB_HOSTNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE); 
     
    // Check connection
     if (mysqli_connect_errno($con))   {
     echo "Failed to connect to MySQL:" . mysqli_connect_error();   
     }
     else echo "CONNECTED TO " . $DB_DATABASE;
    
    // mySQL query
    
    // execute the query.
     $result = $link->query("INSERT INTO oc_test SET text ='12345'") or die("Error in the consult.." . mysqli_error($link));
    		
    ?>

    Такие дела. Простейший скрипт, запускаю с браузера. К базе коннектится, а запросы не выполняет. В чем может быть загвоздка?
    Выдает:
    CONNECTED TO vladbl0m_eshop в базе ничего не меняется. Если просто провести запрос через phpMyAdmin то работает.

    R4s3tsu, 23 Апреля 2014

    Комментарии (10)
  3. C++ / Говнокод #15826

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    #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

    Elvenfighter, 23 Апреля 2014

    Комментарии (3)
  4. PHP / Говнокод #15825

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    <?php header("Content-Type:text/xml"); ?>
    <?php include "config.php"; ?>
    <?php
    if($_GET['operation']=='create'){
    $time=time();
    $add=mysql_query("INSERT INTO photos(`time`) VALUES('".$time."');");
    $id=mysql_insert_id();
    ?><?php echo "<"; ?>?xml version="1.0" encoding="UTF-8" standalone="yes"?<?php echo ">"; ?><image width="0" valid="false" png="false" id="<?php echo $id; ?>" height="0" error="false"><resizes/></image><?php
    exit;
    }
    ?>
    <?php
    $max_width = "90";
    $thumb_width = "40";
    $thumb_height = "40";
    $form_errors=array();
    $formSuccess=false;
    if(isset($_FILES['Filedata']) || $_GET['operation']=='get'){
    	if(isset($_FILES['Filedata'])){
    		if(!is_uploaded_file($_FILES['Filedata']['tmp_name'])){
    			$formSuccess=false;
    			$form_errors['image']="image.uploaded";
    		} elseif(!in_array(strrchr(strtolower(getImageMIME($_FILES['Filedata']['tmp_name'])), '/' ), array('/gif','/jpeg','/png'))){
    			$formSuccess=false;
    			$form_errors['image']="image.type";
    		} elseif($_FILES['Filedata']['size']>1623414){
    			$formSuccess=false;
    			$form_errors['image']="image.size";
    		} elseif(getWidth($_FILES['Filedata']['tmp_name'])<10 || getHeight($_FILES['Filedata']['tmp_name'])<10){
    			$formSuccess=false;
    			$form_errors['image']="image.dimensions";
    		} else {
    			$formSuccess=true;
    		}
    	}
    	if($formSuccess || $_GET['operation']=='get'){
    		$time=time();
    		$topath=str_split(intval($_GET['id']), 2);
    		$topath=array_slice($topath, 0, 3);
    		$topath=implode("/", $topath);
    		$uploaddir = 'media/images/upload/'.$topath.'/';
    		if(isset($_FILES['Filedata'])){
    		@mkdir($uploaddir, 0777, true);
    		}
    		$filename=intval($_GET['id']).'.jpg';
    		$uploadfile = $uploaddir."notready".$filename;
    		if($_GET['operation']=='get'){
    			if(file_exists($uploadfile)){
    				$formSuccess=true;
    			}
    		}
    		if(isset($_FILES['Filedata'])){
    		$write_full=move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadfile);
    		tojpg($uploadfile);
    		}
    		$width=getWidth($uploadfile);
    		$height=getHeight($uploadfile);
    		if(isset($_FILES['Filedata'])){
    		create_square_image($uploadfile, str_replace('notready', 'admin', $uploadfile), 140);
    		create_square_image($uploadfile, str_replace('notready', 'big', $uploadfile), 90);
    		create_square_image($uploadfile, str_replace('notready', 'small', $uploadfile), 40);
    		}
    		$admin_image_data=getWH(str_replace('notready', 'admin', $uploadfile));
    		$big_image_data=getWH(str_replace('notready', 'big', $uploadfile));
    		$small_image_data=getWH(str_replace('notready', 'small', $uploadfile));
    		if(isset($_FILES['Filedata'])){
    		if(isset($_SESSION['userid'])){
    		$_SESSION['avatar']='0';
    		mysql_query("UPDATE `users` SET `avatar`='".intval($_GET['id'])."' WHERE `userid`='".$_SESSION['userid']."';");
    		} else {
    		$_SESSION['avatar']=intval($_GET['id']);
    		}
    		}
    	}
    ?><?php echo "<"; ?>?xml version="1.0" encoding="UTF-8" standalone="yes"?<?php echo ">"; ?><image width="<?php echo intval($width); ?>" valid="<?php if($formSuccess){ echo 'true'; } else { echo 'false'; } ?>" png="false" id="<?php echo intval($_GET['id']); ?>" height="<?php echo intval($height); ?>" error="<?php if($formSuccess){ echo 'false'; } else { echo 'true'; } ?>" newurl="/<?php echo str_replace('notready', 'small', $uploadfile); ?>"><resizes><map name="admin"><imageResize width="<?php echo $admin_image_data['width']; ?>" name="admin" manual="false" id="<?php echo intval($_GET['id']); ?>" height="<?php echo $admin_image_data['height']; ?>" excellent="false"><png>false</png></imageResize></map><map name="big"><imageResize width="<?php echo $big_image_data['width']; ?>" name="big" manual="false" id="<?php echo intval($_GET['id']); ?>" height="<?php echo $big_image_data['width']; ?>" excellent="false"><png>false</png></imageResize></map><map name="small"><imageResize width="<?php echo $small_image_data['width']; ?>" name="small" manual="false" id="<?php echo intval($_GET['id']); ?>" height="<?php echo $small_image_data['width']; ?>" excellent="false"><png>false</png></imageResize></map></resizes></image><?php	
    }
    ?>

    Фрагмент движка официального сайта "Дома-2". Отвечает за AJAX-загрузку аватара.

    hometwo, 22 Апреля 2014

    Комментарии (5)
  5. Куча / Говнокод #15824

    −2

    1. 1
    '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.

    Abbath, 22 Апреля 2014

    Комментарии (0)
  6. Куча / Говнокод #15822

    −1

    1. 1
    }:;(1,5#3)<@}."_1'--T:: ',.~":,.10000+<.6!:0''

    Даты. Теперь на J.

    Abbath, 22 Апреля 2014

    Комментарии (0)
  7. Куча / Говнокод #15821

    +7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    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

    jkhne4pijgberg, 22 Апреля 2014

    Комментарии (12)
  8. Java / Говнокод #15820

    +1

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    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[]) {

    Поиск элемента в массиве

    jkhne4pijgberg, 22 Апреля 2014

    Комментарии (0)
  9. Pascal / Говнокод #15819

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    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)

    jkhne4pijgberg, 22 Апреля 2014

    Комментарии (4)
  10. Python / Говнокод #15818

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    if value is False:
        res = ~res
    elif not value is True:
        raise AnalyzeError("Invalid value {0}".format(condition.value))

    hugr, 22 Апреля 2014

    Комментарии (1)