1. SQL / Говнокод #25625

    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
    select model,(CAST(substring(model, 1, 1) as int)+CAST(substring(model, 2, 1) as int)+CAST(substring(model, 3, 1) as int)+CAST(substring(model, 4, 1) as int)) as qty
    from product
    where  
    (substring(model, 1, 1) like '0' or substring(model, 1, 1) like '1' or substring(model, 1, 1) like '2' 
    or substring(model, 1, 1) like '3' or substring(model, 1, 1) like '4' or substring(model, 1, 1) like '5' 
    or substring(model, 1, 1) like '6' or substring(model, 1, 1) like '7' or substring(model, 1, 1) like '8' 
    or substring(model, 1, 1) like '9')
     AND (substring(model, 2, 1) like '0' or substring(model, 2, 1) like '1' or substring(model, 2, 1) like '2' 
     or substring(model, 2, 1) like '3' or substring(model, 2, 1) like '4' or substring(model, 2, 1) like '5' 
     or substring(model, 2, 1) like '6' or substring(model, 2, 1) like '7' or substring(model, 2, 1) like '8' 
     or substring(model, 2, 1) like '9') 
     AND (substring(model, 3, 1) like '0' or substring(model, 3, 1) like '1' or substring(model, 3, 1) like '2' 
    or substring(model, 3, 1) like '3' or substring(model, 3, 1) like '4' or substring(model, 3, 1) like '5'
     or substring(model, 3, 1) like '6' or substring(model, 3, 1) like '7' or substring(model, 3, 1) like '8' 
     or substring(model, 3, 1) like '9') 
     AND (substring(model, 4, 1) like '0' or substring(model, 4, 1) like '1' or substring(model, 4, 1) like '2'
     or substring(model, 4, 1) like '3' or substring(model, 4, 1) like '4' or substring(model, 4, 1) like '5' 
     or substring(model, 4, 1) like '6' or substring(model, 4, 1) like '7' or substring(model, 4, 1) like '8' 
     or substring(model, 4, 1) like '9')
    
    
    
    select model, 
    ASCII(SUBSTRING(model,1,1))+ 
    ASCII(SUBSTRING(model,2,1))+ 
    ASCII(SUBSTRING(model,3,1))+ 
    ASCII(SUBSTRING(model,4,1)) 
    -48*4 as qty from Product
    тоже не помогло.

    sql ex рейтинговое 4. показывает что на тренировочной что-то не правильно.
    лайк же вроде проверяет '1' как цифру а не как строку.
    любые хинты как тут

    5252mmr, 20 Мая 2019

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

    −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
    select trip_no,concat(CAST(trip_no &1024 aS bit),CAST(trip_no &512 aS bit),CAST(trip_no &256 aS bit), CAST(trip_no &128 aS bit),CAST(trip_no &64 aS bit),
    cast(trip_no & 32 as bit)
     , cast(trip_no & 16 as bit) 
        , cast(trip_no & 8 as bit) 
        , cast(trip_no & 4 as bit) 
        , cast(trip_no & 2 as bit)  
        ,cast(trip_no & 1 as bit)) as trip_no_bit
    from pass_in_trip
    where trip_no<=2048 and trip_no>=1024
    
    union 
    
    select trip_no,concat(CAST(trip_no &1024 aS bit),CAST(trip_no &512 aS bit),CAST(trip_no &256 aS bit), CAST(trip_no &128 aS bit),CAST(trip_no &64 aS bit),
    cast(trip_no & 32 as bit)
     , cast(trip_no & 16 as bit) 
        , cast(trip_no & 8 as bit)
        , cast(trip_no & 4 as bit) 
        , cast(trip_no & 2 as bit)  
        ,cast(trip_no & 1 as bit))  as trip_no_bit
    from trip
    where trip_no<=2048 and trip_no>=1024
    union

    В конкате первый аргумент concat(CAST(trip_no &1024 aS bit),
    &1024 имеется ввиду

    а внизу проверка where trip_no<=2048 and trip_no>=1024 - правильно ли ? или where trip_no<=1024and trip_no>=512 должно быть ?

    и есть ли более профитный вариант решения рейтинговой задачи sqlex`a ? а то какой-то говнокод получается около 11к строк а там лимит 8к...
    или лучше заменить на %2 и /2)%2 , /2)/2)%2 ????

    5252mmr, 20 Мая 2019

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

    +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
    <?php
                          function php2js ($var) {
    			if (is_array($var)) {
    				$res = "[";
    				$array = array();
    				foreach ($var as $a_var) {
    					$array[] = php2js($a_var);
    				}
    				//return "[" . join(",", $array) . "]";
    				return "" . join(",", $array) . "";
    				
    			}
    			elseif (is_bool($var)) {
    				return $var ? "true" : "false";
    			}
    			elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) {
    				return $var;
    			}
    			elseif (is_string($var)) {
    			
    						
    				//return "\"" . addslashes(stripslashes($var)) . "\"";
    				  return "" . addslashes(stripslashes($var)) . "";	
    			}
    		
    			return FALSE;
    		}

    real_escape_string, 19 Мая 2019

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    def test_wash_table_column_name(self):
        testcase_ok = "Programmer"
        testcase_injection = "' OR ''='"
        self.assertEqual(dbquery.real_escape_string(testcase_ok), testcase_ok)

    real_escape_string, 19 Мая 2019

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

    +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
    char *real_escape_string(const byte *src, int size)
    {
        char *escaped;
        char *pos;
    
        if (memchr(src, '\0', size - 1) || memchr(src, '\n', size) || memchr(src, '\r', size)) {
    	fprintf(stderr, "cannot handle this string\n");
    	return NULL;
        }
    
        pos = escaped = malloc(sizeof(char) * (size * 2 + 1));
    
        if (escaped == NULL) {
    	fprintf(stderr, "malloc failed: %m\n");
    	return NULL;
        }
    
        for (int i = 0; i < size; ++i) {
    	if (!isalnum(src[i])) {
    	    *escaped++ = '\\';
    	}
    	*escaped++ = src[i];
        }
    
        *escaped = '\0';
    
        return pos;
    }

    real_escape_string, 19 Мая 2019

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

    −103

    1. 1
    У Страйкера новый бизнес!

    http://govnokod.com/

    Increment_Excrement, 19 Мая 2019

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

    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
    #include <stdio.h>
    #include <conio.h>
    #include <iostream>
    // -------------------------------------------
    #define belugina0 std::wstring("нельзя писать сервера на js")
    #define belugina1 std::wstring("js это обертка для html")
    #define belugina2 std::wstring("Вектор это не динамический массив")
    #define belugina3 std::wstring("-Размер инта? Ответ: "Ну два" ")
    #define belugina4 std::wstring("Бинарным поиском  можно найти максимальное количество минимальных элементов")
    #define belugina5 std::wstring("Бинарным поиском  можно найти сумму элементов массива")
    #define belugina6 std::wstring("Бинарным поиском  можно найти среднее арифметическое массива") 
    #define belugina7 std::wstring("Операцию "перечисления"  это  - когда массив  содержит числа, принадлежащие обоим массивам")
    // наркотики зло
    void main ()
    {
    
    int n; // количество вершин
    int **G;// исходный граф
    int **H; // матрица списка ребер с весом
    int **K; /*матрица, отмечающая принадлежность
    вершины компоненте*/
    int **T; // матрица остовного дерева
    int **L; // список ребер с ценами минимального дерева
    }

    Список моих цитат
    Краткость сестра таланта.

    dethless, 19 Мая 2019

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

    +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
    #include "stdio.h"
    #include "conio.h"
    #define infinity 999
    
    namespace belugina
    {
    void dij(int n,int v,int cost[10][10],int dist[])
    {
     int i,u,count,w,flag[10],min;
     for(i=1;i<=n;i++)
      flag[i]=0,dist[i]=cost[v][i];
     count=2;
     while(count<=n)
     {
      min=99;
      for(w=1;w<=n;w++)
       if(dist[w]<min && !flag[w])
        min=dist[w],u=w;
      flag[u]=1;
      count++;
      for(w=1;w<=n;w++)
       if((dist[u]+cost[u][w]<dist[w]) && !flag[w])
        dist[w]=dist[u]+cost[u][w];
     }
    }
    }

    Я разгадала знак бесконечности.
    #define infinity 999

    dethless, 19 Мая 2019

    Комментарии (12)
  9. C++ / Говнокод #25616

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    namespace 
    {
    struct list {              
    		type  pole1;             
    		list *pole2;             
    } 
    stack; 
    }

    Пример описания стека

    dethless, 19 Мая 2019

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    namespace belugina
    {
    struct list {               
             type elem ;              
             list *next, *pred ;             
    }
    list *headlist ; 
    }

    не могу понять что люблю больше, английски или транслит.

    dethless, 19 Мая 2019

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