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

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

    +131

    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
    #include <stdio.h>
    #include <math.h>
    void out_bin (unsigned short c){
    	for (int i = 11; i>=0; i--) {
    		if ((c & (unsigned short)(1<<i))/(1<<i)==1) printf("1");
    		else printf("0");
    	}
    	printf("\n");
    }
    int main (){
    	int a[8]={2,4,5,6,8,9,10,11};
    	int b[4]={0,1,3,7};
    	int d=0;
    	unsigned short int c=0,c1[4]={0,0,0,0};
    	unsigned char data=165,tdata=176;
    	for(int i=7;i>=0;i--)
    	{ 
    		if (tdata & 128){
    			c+=(unsigned short )(1<<a[i]);
    		}
    		tdata<<=1;
    	}
    	for (int i=0;i<8;i++){
    		unsigned short b = (unsigned short)((c & (unsigned short)(1<<a[i]))/(1<<a[i])) ;
    		if(a[i] & 1) c1[0]^=b;
    		else
    			if(a[i] & 2) c1[1]^=b ;
    			else
    				if(a[i] & 4) c1[2]^=b ;
    				else
    					if(a[i] & 8) c1[3]^=b ;
    	}
    	for (int i = 0; i < 4; i++) {
    		if (!c1[i]) {
    			c|=(unsigned short)(1<<((1<<i)-1));
    		}
    	}
    	printf("Data=      ");
    	out_bin(c);
    	c ^= 256 ;
    	if ((((c & 1024)/1024) ^ ((c & 256)/256) ^ ((c & 64)/64) ^ ((c & 16)/16) ^ ((c & 4)/4) ^ ((c & 1)/1) ) !=1 ){
    		d += 1;
    	}
    	if ((((c & 1024)/1024) ^ ((c & 512)/512) ^ ((c & 64)/64) ^ ((c & 32)/32) ^ ((c & 4)/4) ^ ((c & 2)/2) )  !=1 ){
    		d +=2;
    	}  
    	if ((((c & 2048)/2048) ^ ((c & 64)/64) ^ ((c & 32)/32) ^ ((c & 16)/16) ^ ((c & 8)/8) ) !=1 ){
    		d +=4;
    	}
    	if ((((c & 2048)/2048) ^ ((c & 1024)/1024) ^ ((c & 512)/512) ^ ((c & 256)/256) ^ ((c & 128)/128) )!=1 ){
    		d+=8;
    	}
    	printf("Spoiled=   ");
    	out_bin(c);
    	printf("%d",d);
    	if (d){
    			c ^=(1<<(d-1));
    	}
    	printf("Corrected= ");
    	out_bin(c);
    	return 0;
    }

    Код Хэмминга

    Abbath, 13 Января 2012

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

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Note that async is a contextual keyword. In all syntactic contexts other than the ones above it is considered an identifier. 
    Thus, the following is allowed (though strongly discouraged!):
    
    using async = System.Threading.Tasks.Task;
    …
    async async async(async async) { }

    Из C# Specifications к Visual Studio Async CTP.

    Em1ss1oN, 12 Января 2012

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

    +131

    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
    private static bool state;
    
    public static bool InWork
    {
        get
        {
            return state;
        } 
        internal set
        {
            switch (value)
            {
                case true:
                    {
                        try
                        {
                            // попытка запуска сервиса
                            ...
                        }
                        catch (Exception ex)
                        {
                            throw;
                        }
                    }
                    break;
                case false:
                    {
                        if (!state) return;
                        // попытка остановить сервис
                        ...
                    } 
                    break;
            }
            state = value;
        }
    }
    
    public static void Start(...)
    {
        ...
        InWork = true;
    }
    
    public static void Stop()
    {
        ...
        InWork = false;
    }

    Интересный ход, правда?

    ddv_demon, 01 Декабря 2011

    Комментарии (26)
  5. C# / Говнокод #8511

    +131

    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
    string[] strArray1 = new string[6];
              string[] strArray2 = strArray1;
              int index1 = 0;
              DateTime now = DateTime.Now;
              string str1 = now.Month.ToString();
              strArray2[index1] = str1;
              string[] strArray3 = strArray1;
              int index2 = 1;
              now = DateTime.Now;
              string str2 = now.Day.ToString();
              strArray3[index2] = str2;
              string[] strArray4 = strArray1;
              int index3 = 2;
              now = DateTime.Now;
              string str3 = now.Year.ToString();
              strArray4[index3] = str3;
              string[] strArray5 = strArray1;
              int index4 = 3;
              now = DateTime.Now;
              string str4 = now.Hour.ToString();
              strArray5[index4] = str4;
              string[] strArray6 = strArray1;
              int index5 = 4;
              now = DateTime.Now;
              string str5 = now.Minute.ToString();
              strArray6[index5] = str5;
              string[] strArray7 = strArray1;
              int index6 = 5;
              now = DateTime.Now;
              string str6 = now.Second.ToString();
              strArray7[index6] = str6;
              Program.zipName = string.Concat(strArray1);

    jabacrack, 13 Ноября 2011

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

    +131

    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
    parse(Data) ->
    	io:format("~p~n", [Data]),
    	<<A:8, B:8, C/binary>> = Data,
    	FinalMark = case (bit_nth(0, A)) of 1 -> true; 0 -> false end,
    	MaskMark = case (bit_nth(0, B)) of 1 -> true; 0 -> false end,
    	Result1 = [{final, FinalMark}, {masked, MaskMark}],
    	Opcode = case <<A:4>> of
    		<<16#0:4>> -> continuation_frame;
    		<<16#1:4>> -> text_frame;
    		<<16#2:4>> -> binary_frame;
    		<<16#8:4>> -> connection_closed;
    		<<16#9:4>> -> ping;
    		<<16#a:4>> -> pong;
    		<<_:4>> -> unknown
    	end,
    	Result2 = Result1 ++ [{opcode, Opcode}],
    	<<LengthSign:7>> = <<B:7>>,
    	Length = if
    		LengthSign =< 125 ->
    			C1 = C,
    			LengthSign;
    		LengthSign == 126 ->
    			<<L0:16, C1/binary>> = C, L0;
    		LengthSign == 127 ->
    			<<L0:64, C1/binary>> = C, L0
    	end,
    	Result3 = Result2 ++ [{length, Length}],
    	case MaskMark of
    		true ->
    			<<MaskingKey0:8, MaskingKey1:8, MaskingKey2:8, MaskingKey3:8, C2/binary>> = C1,
    			MaskingKey = [MaskingKey0, MaskingKey1, MaskingKey2, MaskingKey3],
    			Result4 = Result3 ++ [{masking_key, MaskingKey}],
    			Payload = binary_to_list(C2),
    			TX = decode(Payload, lists:reverse(MaskingKey), 0, []);
    		false -> C2 = C1, Result4 = Result3,
    			Payload = binary_to_list(C2), TX = Payload
    	end,
    	Result = Result4 ++ [{msg, TX}],
    	Result.

    Пишу модуль для работы с веб-сокетами на Эрланге. Эта функция парсит и декодирует пакет, присылаемый клиентом.
    Функцию я уже переписал.

    rasufa, 01 Ноября 2011

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

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    data М = М { unМ :: String }
    instance Show М where
        show = map succ . unМ
    
    main = print $ М"ФТИ"

    Синтетический баян...

    kirgo2, 01 Ноября 2011

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

    +131

    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
    #include <stdio.h>
    #include <conio.h>
    #include <locale>
    #include <math.h>
    int main(void)
    {
    	setlocale (LC_ALL, "Russian");
    	char c;
    	printf ("Пожалуйста\, введите символ ");
    	scanf ("%c", &c);
    	
    	switch (c)
    	{
    	case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': printf ("Это цифра"); break;
    	default: printf ("Вы ввели не цифру\!\!\!");
    	}
    	getch ();
    	float x, y1, y2;
    	printf ("\n\n Пожалуйста введите значение \"X\" ");
    	scanf ("%f", &x);
    
    	if ((x<=5)&&(x>3))
    	{
    		y1=log(2*x)+3*x;
    		y2=sqrt(x)+0.75*x;
    		printf ("\n\n При \"X\" = %g\, z(x) имеет два значения: %f и %f", x, y1, y2);
    	}
    	else
    	{
    		{
    		if (x>3)
    		{
    			y1=sqrt(x)+0.75*x;
    			printf ("\n\n При \"X\" = %g\, z(x) = %f", x, y1);
    		}
    		if ((x<=5)&&(x>0))
    		{
    			y1=log(2*x)+3*x;
    			printf ("\n\n При \"X\" = %g\, z(x) = %f", x, y1);
    		}
    		}
    		if (x<=0)
    
    		printf ("\n\n Внимание, введенное значение \"x\" не удолетворяет ОДЗ");
    	}
    		getch ();
    		int pzdc;
    		printf ("\n\n Пожалуйста введите порядковый номер месяца ");
    		scanf ("%d", &pzdc);
    		
    		switch (pzdc)
    		{
    		case 1:
    			printf ("\n 31");
    			break;
    		case 2:
    			printf ("\n 28");
    			break;
    		case 3:
    			printf ("\n 31");
    			break;
    		case 4:
    			printf ("\n 30");
    			break;
    		case 5:
    			printf ("\n 31");
    			break;
    		case 6:
    			printf ("\n 30");
    			break;
    		case 7:
    			printf ("\n 31");
    			break;
    		case 8:
    			printf ("\n 31");
    			break;
    		case 9:
    			printf ("\n 30");
    			break;
    		case 10:
    			printf ("\n 31");
    			break;
    		case 11:
    			printf ("\n 30");
    			break;
    		case 12:
    			printf ("\n 31");
    			break;
    		default:
    			printf ("ОШИБКА!!!"); break;
    		}
    getch ();
    return (0);
    }

    лаба. знаю что тут не любят, но все же

    KirAmp, 26 Октября 2011

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

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    private bool IsChanged(string name, string surname, string patronymic, string email, bool? sex = null, byte[] avatar = null, DateTime? birthDate = null, string address = null)
            {
                bool r1 = sex == null ^ Sex == null ? true : (sex != null ? sex.Value != Sex.Value : true);
                bool r2 = birthDate == null ^ BirthDate == null ? true : (birthDate != null ? birthDate.Value != BirthDate.Value : true);
                bool r3 = address == null ^ Address == null ? true : Address != address;
                bool r4 = avatar == null ^ Avatar == null ? true : (avatar != null ? !Avatar.IsEqual(avatar) : true);
                bool r = Name != name || Surname != surname || Patronymic != patronymic || Email != email;
                return r | r1 | r2 | r3 | r4;
            }

    dotnetdeveloper, 30 Сентября 2011

    Комментарии (16)
  10. Assembler / Говнокод #7943

    +131

    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
    ThreadStarter stru
      this dd ?
      ...
    ends
    
    
    
    ThreadStarter::MoveToArmy near proc
      in ax, 0x40 // initial time
    
      xor cx, cx
      mov dx, ax
    __repeat:
      in ax, 0x40
      lea cx, [ax - dx]
      mov dx, ax
    
      cmp cx, 60 * 60 * 24 * 365
        jl short __repeat
    
      pop ax
      ret
    endp
    
    
    start:
     sub sp, sizeof ThreadStarter
     assume [sp]: stru ThreadStarter
    
     mov ax, sp 
     invoke Thread_Starter::MoveToArmy, ax
    
     ...

    http://www.gamedev.ru/flame/forum/?id=152390#m6

    >14 сен. 2011 17:38
    Машинный код для шестнадцати битного режима
    Все привет. С началом учебы полнейший завал, времени нет вообще. Если вы знаете ссылки на сабж (прерывания, всякие mov, cmp, jmp и т.д.) поделитесь пожалуйста.
    Очень важно, что бы он был для шестнадцати битного режима, для ДОСа, не для Вин32.

    CPPGovno, 22 Сентября 2011

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

    +131

    1. 1
    copy /b *.mpg FullMovie.mpg

    1. Open a blank text file.
    2. Type copy /b *.mpg FullMovie.mpg
    3. Save the file with a .Bat extension.
    Let's say you saved the text file as Joiner.Bat.
    4. Now Copy and Paste this Joiner.Bat file in a folder which contains more than one mpg files.
    5. Double click the Joiner.Bat file.

    Говногость, 27 Июня 2011

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