1. Python / Говнокод #5750

    −179

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    def ispalindrome(string):
    	decide=1
    	i=0
    	while i<=int(len(string)/2) and decide==1:
    		if string[i]!=string[-(i+1)]:
    			decide=0
    		i+=1
    	return decide

    Функция определяет, является ли число паниндромом =)

    SSPkrolik, 21 Февраля 2011

    Комментарии (6)
  2. PHP / Говнокод #5749

    +157

    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
    <?php 
    echo '
    <form method="POST" action="">
    <input type="submit" name="sub" value="Отправить">
    </form>
    ';
    $sub=$_POST['sub'];
    if ($sub==true){
    function rand_foto($patch = "images") 
    { 
    if(!$dir = opendir($patch)) return "images"; 
    while(($t = readdir($dir)) !== false) 
    { 
    $ext = substr(strrchr($t,'.'), 1); 
    if(is_file($t) && ($ext == "gif") || ($ext == "jpg") || ($ext == "png")) 
    { 
    $filename[] = $patch."/".$t; 
    } 
    } 
    closedir($dir); 
    $index = rand(0, count($filename) - 1); 
    $foto = "<img src=".$filename[$index].">"; 
    return $foto; 
    } 
    echo rand_foto(); }

    qbasic, 21 Февраля 2011

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

    +178

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if($active_days > 4)
    {
    	$active_days = 1;
    }
    else
    {
    	if($active_days > 5)
    	{
    		$active_days = 1;
    	}
    }

    В цикле

    vizio, 21 Февраля 2011

    Комментарии (19)
  4. ActionScript / Говнокод #5747

    −241

    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
    while (i < 6) 
    {
        scene.scene["pirat" + i].shot = false;
        scene.scene["pirat" + i].num = i;
        scene.scene["pirat" + i].gotoAndStop(1);
        scene.scene["pirat" + i]._visible = false;
        scene.scene["pirat" + i].swapDepths(10 + i);
        scene.scene["pirat" + i].thisDepth = scene.scene["pirat" + i].getDepth();
        scene.scene["pirat" + i].pirat.piratFall.gotoAndStop(1);
        scene.scene["pirat" + i].pirat.piratFall._visible = false;
        scene.scene["splash" + i].splash1.gotoAndStop(1);
        scene.scene["splash" + i].splash2.gotoAndStop(1);
        scene.scene["splash" + i]._visible = false;
        ++i;
    }

    Данный кусок был найден в недрах флеш-рекламы.

    Govnocoder#0xFF, 21 Февраля 2011

    Комментарии (5)
  5. Java / Говнокод #5746

    +80

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    List<Map<String, Object>> list;
    ...........
    // берем первый элемент списка и сохраняем его
    for(Map<String, Object> properties: list ) {
                map = properties;
                break;
     }

    paralainer, 21 Февраля 2011

    Комментарии (13)
  6. C++ / Говнокод #5745

    +163

    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
    /**
     * Callback for gravity gradient menu option. Turn Gravity Gradient profile display on/off.
     */
    void Exf2dMW::toggleGravGradientProfileCb()
    {
      // GV show Gravity Gradient profile here.
      if (_toggleGravGradientProfileAct->isChecked())
        gvWidget()->showProfiles(1);
      else
        gvWidget()->hideProfiles(1);
    }
    
    /**
     * Callback for gravity menu option. Turn Gravity profile display on/off.
     */
    void Exf2dMW::toggleGravProfileCb()
    {
      // GV show Gravity profile here.
      if (_toggleGravProfileAct->isChecked())
        gvWidget()->showProfiles(2);
      else
        gvWidget()->hideProfiles(2);
    }
    
    /**
     * Callback for magnetic menu option. Turn Magnetic profile display on/off.
     */
    void Exf2dMW::toggleMagProfileCb()
    {
      // GV show magnetic profile here.
      if (_toggleMagProfileAct->isChecked())
        gvWidget()->showProfiles(3);
      else
        gvWidget()->hideProfiles(3);
    }

    boolean logic fail.

    kitaec, 21 Февраля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    foreach($code_array as $code)
    {
    	$code*=1;               //это не тупизм, это самый легкий способ получить из строки число без возможных пробелов
    	if($code==$_POST["code"])
    	{
    		$flag=true;
    		break;
    	}
    }

    intval отменили похоже

    schursin, 21 Февраля 2011

    Комментарии (13)
  8. C++ / Говнокод #5743

    +173

    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
    void DrawingLibrary::drawText(int x0, int y0, char string[], int strlen, int red, int green, int blue, int alpha) {
    	for(int i = 0; i < strlen; ++i) {
    		char chr = string[i];
    		int sX = x0 + i * 8;
    		// проходимся по символам, рисуя их
    		if(chr == '!') {
    			bool symbol[8][8] = {{0,0,0,0,0,1,0,0},{0,0,0,0,0,1,0,0},{0,0,0,0,0,1,0,0},{0,0,0,0,0,1,0,0},{0,0,0,0,0,1,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,1,0,0},{0,0,0,0,0,0,0,0}};
    			this->drawSymbol(sX, y0, symbol, red, green, blue, alpha);
    		}
    		else if(chr == '"') {
    			bool symbol[8][8] = {{0,0,0,0,1,0,1,0},{0,0,0,0,1,0,1,0},{0,0,0,0,1,0,1,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0}};
    			this->drawSymbol(sX, y0, symbol, red, green, blue, alpha);
    		}
    		else if(chr == '#') {
    			bool symbol[8][8] = {{0,0,0,0,1,0,1,0},{0,0,0,0,1,0,1,0},{0,0,0,1,1,1,1,1},{0,0,0,0,1,0,1,0},{0,0,0,1,1,1,1,1},{0,0,0,0,1,0,1,0},{0,0,0,0,1,0,1,0},{0,0,0,0,0,0,0,0}};
    			this->drawSymbol(sX, y0, symbol, red, green, blue, alpha);
    		}
    		/* еще 135 строк такого "кода" */
    		else if(chr == 'э') {
    			bool symbol[8][8] = {{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,1,1,1,0},{0,0,0,0,0,0,0,1},{0,0,0,0,0,1,1,1},{0,0,0,0,0,0,0,1},{0,0,0,0,1,1,1,0},{0,0,0,0,0,0,0,0}};
    			this->drawSymbol(sX, y0, symbol, red, green, blue, alpha);
    		}
    		else if(chr == 'ю') {
    			bool symbol[8][8] = {{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,1,0,0,1,0},{0,0,0,1,0,1,0,1},{0,0,0,1,1,1,0,1},{0,0,0,1,0,1,0,1},{0,0,0,1,0,0,1,0},{0,0,0,0,0,0,0,0}};
    			this->drawSymbol(sX, y0, symbol, red, green, blue, alpha);
    		}
    		else if(chr == 'я') {
    			bool symbol[8][8] = {{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,1,1,1},{0,0,0,0,1,0,0,1},{0,0,0,0,0,1,1,1},{0,0,0,0,0,1,0,1},{0,0,0,0,1,0,0,1},{0,0,0,0,0,0,0,0}};
    			this->drawSymbol(sX, y0, symbol, red, green, blue, alpha);
    		}
    	}
    }

    Функция, рисующая на картинке текст.

    ShitCode, 21 Февраля 2011

    Комментарии (26)
  9. PHP / Говнокод #5742

    +159

    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
    class forms {
        //put your code here
        
        function __construct($name,$id,$method,$action) {
            echo  "<form id='$id' name='id' method='$method' action='$action'>";
        }
        
        static private function attr($param)    {
            if ($param) {
                foreach ($param as $nam_attr => $val_attr) {
                    $attribs.=$nam_attr."='".$val_attr."'";
                }
                return $attribs; 
            }
        }
        static private function label($id,$text,$attr)    {
            $key = array_search('regue', $attr, true);
            if ($key = 1) $text.="<font color='red'>*</font>";
            return "<label for='$id'>$text</label>";
        }
     
        static public function inputs($text,$type,$name,$id,$value=false,$class=false, $attr=false)    {
           
            return self::label($id,$text,$attr)."<input type='$type' name='$name' id='$id' value='$value' class='$class' ".self::attr($attr)."/>";
        }    
        
        static public function inputs_chek($text,$type,$name,$id,$value=false,$class=false, $attr=false)    {
            return  self::label($id,$text,$attr)."<input type='$type' name='$name' id='$id' class='$class' ".self::attr($attr)."/>$value";
        }   
        
        static public function area($text,$name,$id,$value=false,$class=false, $attr=false)    {
            return  self::label($id,$text,$attr)."<TEXTAREA NAME='$name' id='$id' WRAP='virtual' COLS='40' ROWS='3' ".self::attr($attr).">$value</TEXTAREA>";
        } 
        
        static public function select($text,$name,$id,$value=false,$class=false, $attr=false)    {
            $select="<select name='$name' id='$id' ".self::attr($attr).">";
            foreach($value as $value => $val_text)  {
                $select.="<option value='$value'>$val_text</option>";
            }
           $select.="</select>";
           return  self::label($id,$text,$attr).$select;
        } 
        
        function __destruct() {
            echo "<input type='submit'/><input type='reset' value='Очистить'></form>";
        }   
    }

    qbasic, 21 Февраля 2011

    Комментарии (6)
  10. JavaScript / Говнокод #5741

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    function auCtrl(whSound,play) {
    if (IE) this.src = play? aySound[whSound]:'';
    else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
    }

    ___, 21 Февраля 2011

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