1. Pascal / Говнокод #2972

    +110

    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
    Function IsBigLet(Let: String): Boolean;
    var r: bool;
    begin
    r:=false;
    if pos('Й',Let)>0 then r:=true;
    if pos('Ц',Let)>0 then r:=true;
    if pos('У',Let)>0 then r:=true;
    if pos('К',Let)>0 then r:=true;
    if pos('Е',Let)>0 then r:=true;
    if pos('Н',Let)>0 then r:=true;
    if pos('Г',Let)>0 then r:=true;
    if pos('Ш',Let)>0 then r:=true;
    if pos('Щ',Let)>0 then r:=true;
    if pos('З',Let)>0 then r:=true;
    if pos('Х',Let)>0 then r:=true;
    if pos('Ф',Let)>0 then r:=true;
    if pos('Ы',Let)>0 then r:=true;
    if pos('В',Let)>0 then r:=true;
    if pos('А',Let)>0 then r:=true;
    if pos('П',Let)>0 then r:=true;
    if pos('Р',Let)>0 then r:=true;
    if pos('О',Let)>0 then r:=true;
    if pos('Л',Let)>0 then r:=true;
    if pos('Д',Let)>0 then r:=true;
    if pos('Ж',Let)>0 then r:=true;
    if pos('Э',Let)>0 then r:=true;
    if pos('Я',Let)>0 then r:=true;
    if pos('Ч',Let)>0 then r:=true;
    if pos('С',Let)>0 then r:=true;
    if pos('М',Let)>0 then r:=true;
    if pos('И',Let)>0 then r:=true;
    if pos('Т',Let)>0 then r:=true;
    if pos('Б',Let)>0 then r:=true;
    if pos('Ю',Let)>0 then r:=true;
    Result:=r;
    end;

    Немножко индусского кода!

    Temnenkov, 09 Апреля 2010

    Комментарии (23)
  2. C++ / Говнокод #2971

    +60.2

    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
    bool CMLayer::operator==(CMLayer ^a, CMLayer ^b)
    {
    	CLayer *pA;
    	CLayer *pB;
    	bool bA = false;
    	bool bB = false;
    
    	// Проверка в катче
    	try
    	{
    		pA = a->m_pelMain;
    	}
    	catch (System::NullReferenceException ^)
    	{
    		pA = NULL;
    		bA = true;
    	}
    
    	// Проверка в катче
    	try
    	{
    		pB = b->m_pelMain;
    	}
    	catch (System::NullReferenceException ^)
    	{
    		pB = NULL;
    		bB = true;
    	}
    
    	if ((bA == true) && (bB == true))
    		return true;
    	else if ((bA == true) || (bB == true))
    		return false;
    
    	return pA == pB;
    }

    Код на Management C++, тот кто его писал был явно в ажуре))))
    Проверяются указатели на внутрении данные, а штоб System::NullReferenceException не выскакивал при сравнее на null все сделанно в катче

    Snake2101, 09 Апреля 2010

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

    +144.8

    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
    99. 99
    bool PathProcessor::Process(PPProcess *pProcess)
    {
    	std::vector<int> viRoute; int nRouteCount; bool bRetVal = false;
    	for (int i = 0; i < m_viExcludeStop.size(); i++){
    		if (m_viExcludeStop[i] == pProcess->nStartStopId) return false;
    	}
    	int bbb = 0;
    	if (pProcess->nRouteId < 0){
    		viRoute = GetRoutesID(pProcess->nStartStopId);
    		nRouteCount = viRoute.size();
    		if (nRouteCount <= 0) return false;
    	}
    	else{
    		viRoute = GetRoutesID(pProcess->nStartStopId, pProcess->nRouteId);
    		nRouteCount = viRoute.size();
    		if (nRouteCount <= 0) return false;
    		nRouteCount = 1;
    	}
    	for (int i = 0; i < nRouteCount; i++){
    		RouteDataInfo rdCur = GetRoute(viRoute[i]);
    		pProcess->nRoutePartId = rdCur.nId;
    		PPResult *pRes;
    		bool bCurRetVal = false;
    		if (pProcess->bIsFirstStop == true){
    			pRes = new PPResult();
    			pRes->bFinished = false;
    			pRes->nFirstStopId = pProcess->nFirstId;
    			pRes->nLastStopId = -1;
    			pRes->nRouteId = rdCur.nRouteId;
    			m_viResult.push_back(pRes);
    		}
    		else pRes = pProcess->pLastResult;
    		if (pRes != NULL){
    			PartInfo piTemp(rdCur.nId, rdCur.nLastStopId);
    			pRes->viPartsId.push_back(piTemp);
    		}
    		if (IsEndStop(rdCur.nLastStopId) == true){
    			if (pRes != NULL){
    				pRes->bFinished = true;
    				pRes->nLastStopId = rdCur.nLastStopId;
    			}
    			bRetVal = true;	bCurRetVal = true;
    		}
    		if ((pProcess->IsStopExist(rdCur.nLastStopId) == false) && (bCurRetVal == false)){
    			if ((pProcess->nCurStep < m_nMaxStep) && (pProcess->nRouteId >= 0)){
    				PPProcess ppProc;
    				ppProc.nCurStep = pProcess->nCurStep;
    				ppProc.nRouteId = pProcess->nRouteId;
    				ppProc.nStartStopId = rdCur.nLastStopId;
    				ppProc.pPrevProc = pProcess;
    				ppProc.bIsFirstStop = false;
    				ppProc.nFirstId = pProcess->nFirstId;
    				if (pProcess->pLastResult == NULL) ppProc.pLastResult = pRes;
    				else ppProc.pLastResult = pProcess->pLastResult;
    				if (Process(&ppProc) == true) bRetVal = true;
    			}
    			else if (pProcess->nCurStep < m_nMaxStep){
    				PPProcess ppProc;
    				ppProc.nCurStep = pProcess->nCurStep;
    				ppProc.nRouteId = rdCur.nRouteId;
    				ppProc.nStartStopId = rdCur.nLastStopId;
    				ppProc.pPrevProc = pProcess;
    				ppProc.bIsFirstStop = false;
    				ppProc.nFirstId = pProcess->nFirstId;
    				if (pProcess->pLastResult == NULL) ppProc.pLastResult = pRes;
    				else ppProc.pLastResult = pProcess->pLastResult;
    				if (Process(&ppProc) == true) bRetVal = true;
    			}
    			if (pProcess->nCurStep+1 < m_nMaxStep){
    				PPProcess ppProc2;
    				ppProc2.nCurStep = pProcess->nCurStep+1;
    				ppProc2.nRouteId = -1;
    				ppProc2.nStartStopId = rdCur.nLastStopId;
    				ppProc2.pPrevProc = pProcess;
    				ppProc2.bIsFirstStop = true;
    				ppProc2.nFirstId = rdCur.nLastStopId;
    				ppProc2.pLastResult = NULL;
    				if (Process(&ppProc2) == true){
    					PPResult *pRes2;
    					pRes2 = new PPResult();
    					pRes2->bFinished = true;
    					pRes2->nFirstStopId = pRes->nFirstStopId;
    					pRes2->nLastStopId = rdCur.nLastStopId;
    					pRes2->nRouteId = pRes->nRouteId;
    					PPProcess *pProc = pProcess;
    					while (pProc != NULL){
    						PartInfo piTemp(pProc->nRoutePartId, pProc->nStartStopId);
    						pRes2->viPartsId.push_back(piTemp);
    						pProc = pProc->pPrevProc;
    					}
    					m_viResult.push_back(pRes2); bRetVal = true;
    				}
    			}
    		}
    	}
    	if ((bRetVal == false) && (pProcess->nRouteId < 0))
    		m_viExcludeStop.push_back(pProcess->nStartStopId);
    	return bRetVal;
    }

    Когда-то давно писал алгоритм поиска маршрутов, теперь удевляюсь как это все работает да еще и не виснет

    Snake2101, 09 Апреля 2010

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

    +144.8

    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
    #include "stdafx.h"
    #include "windows.h"
    
    #define число int
    #define если if
    #define иначе else
    #define начало {
    #define конец }
    #define НОЛЬ NULL
    #define Сообщение MessageBoxA
    #define КНОПКА_ОК MB_OK
    #define возврат
    #define присвоить =
    #define равняется ==
    #define больше >
    #define ТочкаВхода _tmain
    #define Строка _TCHAR
    #define УКАЗАТЕЛЬ *
    #define КонецСтроки ;
    #define СлучайноеЧисло rand
    #define Посев srand
    #define ВзятьКоличествоТиков GetTickCount
    
    /****************************************************************************************************/
    /*																									*/
    /****************************************************************************************************/
    число ТочкаВхода(число КоличествоПараметров, Строка УКАЗАТЕЛЬ Параметры[])
    {
    	Посев(ВзятьКоличествоТиков());
    	число новое присвоить СлучайноеЧисло() КонецСтроки
    	если (новое больше 10000) начало
    		Сообщение(НОЛЬ, "Больше 10000", НОЛЬ, КНОПКА_ОК) КонецСтроки
    	конец иначе начало
    		Сообщение(НОЛЬ, "Меньше 10000", НОЛЬ, КНОПКА_ОК) КонецСтроки
    	конец
    
    	возврат 0 КонецСтроки
    }

    Ооо могучий C++

    Snake2101, 09 Апреля 2010

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

    +129.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len);
        if (new == NULL) {
            return NGX_CONF_ERROR;
        }
    
        p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1);
        ngx_memcpy(p, domain->data, domain->len);
    
        domain->len += sizeof("; domain=") - 1;

    Это, между прочим, файл nginx-0.7.62\src\http\modules\ngx_http_userid_ filter_module.c.
    Такие вот разочарования случаются...

    dmitry_113, 08 Апреля 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    List<Student> students = new List<Student>
            {
               new Student {LastName="Omelchenko", Scores= new List<int> {97, 72, 81, 60}},
               new Student {LastName="O'Donnell", Scores= new List<int> {75, 84, 91, 39}},
               new Student {LastName="Mortensen", Scores= new List<int> {88, 94, 65, 85}},
               new Student {LastName="Garcia", Scores= new List<int> {97, 89, 85, 82}},
               new Student {LastName="Beebe", Scores= new List<int> {35, 72, 91, 70}} 
            };

    Говногость, 08 Апреля 2010

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

    +144.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    A* arr = new A[size];
    std::vector<A*> vec(size);
    for(size_t i=0; i<size; ++i)
    	vec.push_back(&a[i])
    // Do something with vec
    delete[] arr;

    kokorins, 08 Апреля 2010

    Комментарии (9)
  8. 1C / Говнокод #2965

    −128.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Перем Да, Нет Экспорт;
    
    Да  = 1;
    Нет = 0;
    
    и далее в кодах идет 
    Если <что то>=Да Тогда
    ....
    КонецЕсли;

    сразу скажу....это все пишется в 1С 7.7

    походу ребятки ПЕРЕКОДИЛИ в 8-ке и снова вернулись на 7-ку

    s.komaroff, 08 Апреля 2010

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

    +151.6

    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
    ##	типа база для копипаста. изначально intval отсутствовал, но не суть важно
    	$sqll='select tt.title as titletag, t.id_news as id, DATE_FORMAT(n_d.data, "'.DATE_FORMAT.'") as data, n.title as titlenews, n.subject from  '.T_TAGS.' as tt, '.T_NEWS_TAGS.' as t, '.T_ANALIT_DATA.' as n , '.T_ANALIT.' as n_d where t.id_news=n.news_id and n.news_id=n_d.id and t.id_tags="'.intval($_GET["param2"]).'"  and t.id_tags=tt.id  order by n_d.data desc';
    	$resultt = $DB->Execute($sqll) or DB_Error(__LINE__, $sqll, $DB);
    	$block='main.news';
    	while ($roww = $resultt->FetchRow())	{
    		foreach ($roww as $_key=>$_value)	$xtpl->assign($_key,	stripslashes($_value));
    		$xtpl->assign('titletag',	$roww['titletag']);
    		$xtpl->assign('title_title',	$roww['titletag']);
        $xtpl->parse($block.'.newstags.row');
    	}			
    
    ##	аццкий отжиг
    	$sqll='select tt.descr from  '.T_TAGS.' as tt, '.T_NEWS_TAGS.' as t, '.T_ANALIT_DATA.' as n , '.T_ANALIT.' as n_d where t.id_news=n.news_id and n.news_id=n_d.id and t.id_tags="'.intval($_GET["param2"]).'"  and t.id_tags=tt.id order by n_d.data desc';
    	$resultt = $DB->Execute($sqll) or DB_Error(__LINE__, $sqll, $DB);
    	$roww = $resultt->FetchRow();
    	foreach ($roww as $_key=>$_value)	$xtpl->assign($_key,	stripslashes($_value));
    	if($roww['descr']!='') $xtpl->parse($block.'.newstags.descr');

    копипаст неискореним.

    ufdyjrjlth, 08 Апреля 2010

    Комментарии (8)
  10. PHP / Говнокод #2963

    +143.6

    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
    <?php 
    try { 
        $mysqlhost = "localhost"; 
        $mysqluser = "root"; 
        $mysqlpass = ""; 
        if ($db = mysql_connect ($mysqlhost,$mysqluser,$mysqlpass)){ 
            echo "Successfully connected to the database."; 
            mysql_close ($db); 
        
        } else { 
            throw new exception ("Sorry, could not connect to mysql."); 
        } 
    } catch (exception $e) { 
    echo $e->getmessage (); 
    } 
    ?>

    как не надо подключаться к mysql

    sergylens, 08 Апреля 2010

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