1. Список говнокодов пользователя Nyamka

    Всего: 2

  2. C# / Говнокод #25306

    +3

    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
    private static byte shitleft(byte shiftbyte, int shiftno)
    {
        string newbyte2 = Convert.ToString(shiftbyte, 2);
        newbyte2 = newbyte2.PadLeft(8, '0');
    
        string newbyte = "";
        if (shiftno == 0) return shiftbyte;
        else if (shiftno > 7) return 0;
    
        for (int bytecount = 0 + shiftno; bytecount < shiftno + 8; bytecount++)
        {
            if (bytecount > 7) newbyte += newbyte2[bytecount - 8].ToString();
            else newbyte += newbyte2[bytecount].ToString();
        }
        return Convert.ToByte(newbyte, 2);
    }

    Циклический сдвиг. Тоже самое без проверок: (byte)((shiftbyte << shiftno) | (shiftbyte >> (8 - shiftno)))

    Nyamka, 13 Января 2019

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

    +4

    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
    #include <stdio.h>
    #include <string>
    
    const struct FooAgeProperty {} age;
    const struct FooNameProperty {} name;
    
    template <typename T>
    struct FooPropertyAssignment {
    	FooPropertyAssignment(T* prop): prop(prop) { }
    
    	T* prop;
    };
    
    struct years {
    	int i;
    
    	years& operator=(FooPropertyAssignment<int> fpa) {
    		*fpa.prop = i;
    		return *this;
    	}
    };
    
    struct nam {
    	std::string s;
    
    	nam& operator=(FooPropertyAssignment<std::string> fpa) {
    		*fpa.prop = s;
    		return *this;
    	}
    };
    
    years operator""years(unsigned long long value) {
    	return { (int)value };
    }
    
    nam operator""_(const char* value, size_t) {
    	return { value };
    }
    
    struct NegativeFoo {
    	NegativeFoo(int* age, std::string* name): age(age), name(name) {}
    
    	int* age;
    	std::string* name;
    };
    
    FooPropertyAssignment<int> operator<(FooAgeProperty fap, NegativeFoo nfoo) {
    	return FooPropertyAssignment<int>(nfoo.age);
    }
    
    FooPropertyAssignment<std::string> operator<(FooNameProperty fnp, NegativeFoo nfoo) {
    	return FooPropertyAssignment<std::string>(nfoo.name);
    }
    
    struct Foo;
    Foo* nasty_global_variable;
    
    struct Foo {
    	Foo() {
    		nasty_global_variable = this;
    	}
    
    	NegativeFoo operator-() {
    		return NegativeFoo(&age, &name);
    	}
    
    	int age;
    	std::string name;
    };
    
    struct to_string {
    	struct foo {
    		foo(int (*)(const char*, ...)) {
    			printf(".old years %d am I and %s is name My\n", nasty_global_variable->age, nasty_global_variable->name.c_str());
    		}
    	};
    };
    
    int main() {
    	Foo foo;
    	5years = age<-foo;
    	"Billy"_ = name<-foo;
    	(to_string::foo)printf;
    }

    https://www.reddit.com/r/ProgrammerHumor/comments/acv2og/just_wrote_my_first_program_in_c/

    Nyamka, 06 Января 2019

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