1. Лучший говнокод

    В номинации:
    За время:
  2. C# / Говнокод #3585

    +141

    1. 1
    2. 2
    3. 3
    if(i.ToString()==j.ToString())
    {
    //...

    Из моей детсадовской лабы. С тех пор я профессионально вырос.

    Wеbkill, 28 Июня 2010

    Комментарии (6)
  3. Си / Говнокод #3454

    +141

    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
    #include <stdio.h>
    
    int main() {
    	unsigned d,t,k;
    	scanf("%d",&d);
    	t=d;
    	for(k=0;t!=0;k++) //определяем кол-во значащих битов
    		t>>=1;
    	//обнуляем старший значащий бит
    	d<<=sizeof(d)*8-k+1; 
    	d>>=sizeof(d)*8-k+1; 
    	return 0;
    }

    Вот такое вот обнуление старшего бита

    movaxbx, 11 Июня 2010

    Комментарии (41)
  4. Си / Говнокод #3387

    +141

    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
    for (int x=0; x < TANK_SIZE; x++)
    
    	{
    
    		for (int y=0; y < TANK_SIZE; y++)
    
    		{
    
    			*((Uint32 *)(((Uint8 *)player_surface[DOWN]->pixels) + (TANK_SIZE - y - 1) * player_surface[DOWN]->pitch + (TANK_SIZE - x - 1) * player_surface[DOWN]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[LEFT]->pixels) + (TANK_SIZE - x - 1) * player_surface[LEFT]->pitch + y * player_surface[LEFT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[RIGHT]->pixels) + x * player_surface[RIGHT]->pitch + (TANK_SIZE - y - 1) * player_surface[RIGHT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[UP]->pixels) + y * player_surface[UP]->pitch + x * player_surface[UP]->format->BytesPerPixel));
    
    			*((Uint32 *)(((Uint8 *)enemy_surface[DOWN]->pixels) + (TANK_SIZE - y - 1) * enemy_surface[DOWN]->pitch + (TANK_SIZE - x - 1) * enemy_surface[DOWN]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[LEFT]->pixels) + (TANK_SIZE - x - 1) * enemy_surface[LEFT]->pitch + y * enemy_surface[LEFT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[RIGHT]->pixels) + x * enemy_surface[RIGHT]->pitch + (TANK_SIZE - y - 1) * enemy_surface[RIGHT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[UP]->pixels) + y * enemy_surface[UP]->pitch + x * enemy_surface[UP]->format->BytesPerPixel));
    
    			
    
    		}
    
    	}

    dageru, 03 Июня 2010

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

    +141

    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
    /* Putarc1 печатает точки, определяющие дугу от 0 до 45.*/
    void Putarc1(HIMAGE *Im,short x, short y, short x_center, short y_center, unsigned char color){
    	 int  starty, endy, y1;
    	 starty=y; endy=(y+1);
    	 for (y1=starty;y1<endy;++y1) PutPoint(Im,y1+x_center,y_center-x,color);
    }
    /* Putarc2 печатает точки, определяющие дугу от 45 до 90.*/
    void Putarc2(HIMAGE *Im,short x, short y, short x_center, short y_center, unsigned char color){
    	 int startx, endx, x1;
    	 startx=x; endx=(x+1);
    	 for (x1=startx;x1<endx;++x1) PutPoint(Im,x1+x_center,y_center-y,color);
    }
    /* Putarc3 печатает точки, определяющие дугу от 90 до 135.*/
    void Putarc3(HIMAGE *Im,short x, short y, short x_center, short y_center, unsigned char color){
    	 int startx,endx,x1;
    	 startx=x; endx=(x+1);
    	 for (x1=startx;x1<endx;++x1) PutPoint(Im,x_center-x1,y_center-y,color);
    }
    /* Putarc4 печатает точки, определяющие дугу от 135 до 180.*/
    void Putarc4(HIMAGE *Im,short x, short y, short x_center, short y_center,unsigned char color){
    	 int starty,endy,y1;
    	 starty=y; endy=(y+1);
    	 for (y1=starty;y1<endy;++y1) PutPoint(Im,x_center-y1,y_center-x,color);
    }
    /* Putarc5 печатает точки, определяющие дугу от 180 до 225.*/
    void Putarc5(HIMAGE *Im,short x, short y, short x_center, short y_center,unsigned char color){
    	 int starty,endy,y1;
    	 starty=y; endy=(y+1);
    	 for (y1=starty;y1<endy;++y1) PutPoint(Im,x_center-y1,x+y_center,color);
    }
    /* Putarc6 печатает точки, определяющие дугу от 225 до 270.*/
    void Putarc6(HIMAGE *Im,short x, short y, short x_center, short y_center,unsigned char color){
    	 int startx,endx,x1;
    	 startx=x*1.0; endx=(x+1)*1.0;
    	 for (x1=startx;x1<endx;++x1) PutPoint(Im,x_center-x1,y+y_center,color);
    }
    /* Putarc7 печатает точки, определяющие дугу от 270 до 315.*/
    void Putarc7(HIMAGE *Im,short x, short y, short x_center, short y_center, unsigned char color){
    	 int startx, endx, x1;
    	 startx=x; endx=(x+1);
    	 for (x1=startx;x1<endx;++x1) PutPoint(Im,x1+x_center,y+y_center, color);
    }
    /* Putarc8 печатает точки, определяющие дугу от 315 до 360.*/
    void Putarc8(HIMAGE *Im,short x, short y, short x_center, short y_center, unsigned char color) {
    	 int  starty,endy,y1;
    	 starty=y; endy=(y+1);
    	 for (y1=starty;y1<endy;++y1) PutPoint(Im,y1+x_center,x+y_center,color);
    }

    Рисуем дуги кусками по 45 градусов

    absolut, 24 Мая 2010

    Комментарии (3)
  6. Си / Говнокод #3079

    +141

    1. 1
    #define ass assert (false)

    ...

    XAKEP, 22 Апреля 2010

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

    +141

    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
    $query =
                'SELECT * ' .
                'FROM `requests` ' .
                'WHERE `requests`.`uid` = \'' . mysql_escape_string($uid) . '\' ' .
                'AND `requests`.`status` = 0 ' .
                '';
            $requests = $this->execQuery($query);
            if ( !$requests) {
                $this->lastError = 'Error getting user\'s data. ';
                return false;
            } else {
                $questions = $this->findAllQuestions();
                foreach ($requests as $n => $request) {
                    $requests[$n]['quiz'] = unserialize(
                        unserialize($request['quiz'])
                    );
                    foreach ($requests[$n]['quiz'] as $qid => $answer) {
                        $currentQuestion = &$requests[$n]['quiz'][$qid];
                        $currentQuestion = array();
                        $currentQuestion['qid'] = $qid;
                        if (is_array($questions[$qid]['answers'])) {
                            $currentQuestion['question'] = $questions[$qid]['question'];
                            $currentQuestion['aid'] = $answer;
                            $currentQuestion['answer'] = $questions[$qid]['answers'][$answer]['answer'];;
                        } else {
                            $currentQuestion['question'] = $questions[$qid]['question'];
                            $currentQuestion['aid'] = null;
                            $currentQuestion['answer'] = $answer;
                        }
                    }
                }
            }
            return $requests;
        }

    Я, честно говоря, так и не разобрался что "это" делает...

    Bartelby, 07 Октября 2009

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function isBrowserUeban()
    {
    	if (navigator.userAgent.match(/MSIE 6/i) != null) return 1;
    	else if (navigator.userAgent.match(/MSIE 7/i) != null) return 2;
    	else return 0;
    }

    кратко и по сути
    PS код писался когда ie8 не было

    saratovdae, 21 Августа 2009

    Комментарии (2)
  9. Си / Говнокод #1473

    +141

    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
    Stess  (21:31:33 5/08/2009)
    блин..я мало ем...просто полнею и все...ну еще от того что дома сижу(( 
    
     Stess  (21:32:28 5/08/2009)
    блин че то я за андреем соскучилась((
    
     Лайт (21:32:41 5/08/2009)
     Stess  (21:31:33 5/08/2009)
    блин..я мало ем...просто полнею и все...ну еще от того что дома сижу(( 
    
     Лайт (21:32:43 5/08/2009)
    хммм...
    
     Лайт (21:32:47 5/08/2009)
    надо с тобой заняться
    
     Лайт (21:32:49 5/08/2009)
    ...
    
     Лайт (21:32:51 5/08/2009)
    тобой
    
     Stess  (21:33:01 5/08/2009)
    чем???
    
     Лайт (21:33:10 5/08/2009)
    тобой
    
     Лайт (21:33:15 5/08/2009)
    или...чем хочешь
    
     Stess  (21:33:39 5/08/2009)
    блин.. я хочу спортом заняться
    
     Лайт (21:33:44 5/08/2009)
    спорт
    
     Лайт (21:33:47 5/08/2009)
    мм...
    
     Лайт (21:33:51 5/08/2009)
    бокс)
    
     Stess  (21:33:55 5/08/2009)
    нет
    
     Лайт (21:33:58 5/08/2009)
    тейквандо
    
     Лайт (21:34:00 5/08/2009)
    карате
    
     Лайт (21:34:02 5/08/2009)
    дзюдо
    
     Stess  (21:34:05 5/08/2009)
    там бегать по вечерам
    
     Лайт (21:34:06 5/08/2009)
    легкая атлетика
    
     Лайт (21:34:08 5/08/2009)
    
    
     Лайт (21:34:14 5/08/2009)
    бегать по вечерам одной скучно)
    
     Лайт (21:34:22 5/08/2009)
    и эт не спорт
    
     Лайт (21:34:25 5/08/2009)
    над экстрим
    
     Stess  (21:34:34 5/08/2009)
    ну вот)) я ща ищу человека кто захочет со мной бегать)))
    
     Лайт (21:34:38 5/08/2009)
    бег по пересеченной местности с перпятствиями от собаки
    
     Stess  (21:34:40 5/08/2009)
    потом на роликах

    СОЦ инженерия :)

    guest, 05 Августа 2009

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

    +141

    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
    try
    {
       fIn = fopen(cszFileName, "rb");
       if (fIn == 0)
         throw (std::string("Can not open file: ") + cszFileName);
      
       if (!ParseFile(fIn, pLookup))
         throw (std::string("Bad file format. File: ") + cszFileName);
     
       throw std::string("");
    }
    catch (std::string& e)
    {
       if (fIn != 0)
       {
          fclose(fIn);
          fIn = NULL;
       }
       if (e.length() != 0)
       {
          throw std::exception(e.c_str());
       }
    }

    Исправленный говнокод

    guest, 04 Августа 2009

    Комментарии (9)
  11. Си / Говнокод #1275

    +141

    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
    typedef INTEGER int
    typedef BOOLEAN bool
    #define TRUE true
    #define FALSE false
    #define BEGIN {
    #define END }
    #define WHILE(a) while(a)
    #define REPEAT do{
    #define UNTIL(a) }while(!(a))
    #define FOR for(
    #define TO(a,b) ,a<b
    #define DO(a) ,a++)
    #define VAR
    #define IF if
    #define THEN
    ...
    VAR
    INTEGER I;
    BEGIN
    I=2;
    REPEAT
    ...
    I=I+1;
    UNTIL I<5;
    ...
    END
    ...

    Что этот парень пытался сделать с Си? O_o

    guest, 28 Июня 2009

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