1. C++ / Говнокод #23170

    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
    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
    int32 documentColorIndex(DocumentData *document, QString &ext) {
    	int32 colorIndex = 0;
    
    	QString name = document ? (document->name.isEmpty() ? (document->sticker() ? lang(lng_in_dlg_sticker) : qsl("Unknown File")) : document->name) : lang(lng_message_empty);
    	name = name.toLower();
    	int32 lastDot = name.lastIndexOf('.');
    	QString mime = document ? document->mime.toLower() : QString();
    	if (name.endsWith(qstr(".doc")) ||
    		name.endsWith(qstr(".txt")) ||
    		name.endsWith(qstr(".psd")) ||
    		mime.startsWith(qstr("text/"))
    		) {
    		colorIndex = 0;
    	} else if (
    		name.endsWith(qstr(".xls")) ||
    		name.endsWith(qstr(".csv"))
    		) {
    		colorIndex = 1;
    	} else if (
    		name.endsWith(qstr(".pdf")) ||
    		name.endsWith(qstr(".ppt")) ||
    		name.endsWith(qstr(".key"))
    		) {
    		colorIndex = 2;
    	} else if (
    		name.endsWith(qstr(".zip")) ||
    		name.endsWith(qstr(".rar")) ||
    		name.endsWith(qstr(".ai")) ||
    		name.endsWith(qstr(".mp3")) ||
    		name.endsWith(qstr(".mov")) ||
    		name.endsWith(qstr(".avi"))
    		) {
    		colorIndex = 3;
    	} else {
    		QChar ch = (lastDot >= 0 && lastDot + 1 < name.size()) ? name.at(lastDot + 1) : (name.isEmpty() ? (mime.isEmpty() ? '0' : mime.at(0)) : name.at(0));
    		colorIndex = (ch.unicode() % 4);
    	}
    
    	ext = document ? ((lastDot < 0 || lastDot + 2 > name.size()) ? name : name.mid(lastDot + 1)) : QString();
    
    	return colorIndex;
    }

    https://github.com/telegramdesktop/tdesktop/blob/5f5770dd46491133b135a71fc2d4f92d13107ade/Telegram/SourceFiles/layout.cpp#L170-L211

    херь из исходниктв Telegram Desktop

    j123123, 10 Июля 2017

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

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    switch (address & 0xF000)
        {
            case 0x0000:
            case 0x1000:
            case 0x2000:
            case 0x3000:
                return rom[address];
            case 0x4000:
            case 0x5000:
            case 0x6000:
            case 0x7000:
                return rom[address + 0x4000 * (bank_index - 1)];
            case 0x8000:
            case 0x9000:
                return vram[address - 0x8000];
            case 0xA000:
            case 0xB000:
                return sram[address - 0xA000];
            case 0xC000:
            case 0xD000:
                return wram[address - 0xC000];
            case 0xE000:
            case 0xF000:
                switch (address & 0x0F00)
                {
                    case 0x0000:
                    case 0x0100:
                    case 0x0200:
                    case 0x0300:
                    case 0x0400:
                    case 0x0500:
                    case 0x0600:
                    case 0x0700:
                    case 0x0800:
                    case 0x0900:
                    case 0x0A00:
                    case 0x0B00:
                    case 0x0C00:
                    case 0x0D00:
                        return wram[address - 0xF000];
                    case 0x0E00:
                        switch (address & 0x00F0)
                        {
                            case 0x0000:
                            case 0x0010:
                            case 0x0020:
                            case 0x0030:
                            case 0x0040:
                            case 0x0050:
                            case 0x0060:
                            case 0x0070:
                            case 0x0080:
                            case 0x0090:
                                return oam[address - 0xFE00];
                            case 0x00A0:
                            case 0x00B0:
                            case 0x00C0:
                            case 0x00D0:
                            case 0x00E0:
                            case 0x00F0:
                                return 0b00;
                        }
                    case 0x0F00:
                        switch (address & 0x00F0)
                        {
                            case 0x0000:
                            case 0x0010:
                            case 0x0020:
                            case 0x0030:
                            case 0x0040:
                            case 0x0050:
                            case 0x0060:
                            case 0x0070:
                                return io_regs[address - 0xFF00];
                            case 0x0080:
                            case 0x0090:
                            case 0x00A0:
                            case 0x00B0:
                            case 0x00C0:
                            case 0x00D0:
                            case 0x00E0:
                            case 0x00F0:
                                switch (address & 0x000F)
                                {
                                    case 0x0000:
                                    case 0x0001:
                                    case 0x0002:
                                    case 0x0003:
                                    case 0x0004:
                                    case 0x0005:
                                    case 0x0007:
                                    case 0x0008:
                                    case 0x0009:
                                    case 0x000A:
                                    case 0x000B:
                                    case 0x000C:
                                    case 0x000D:
                                    case 0x000E:
                                        return hram[address - 0xFF80];
                                    case 0x000F:

    jangolare, 06 Июля 2017

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

    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
    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
    #include <optional>
    
    namespace aim {
    
            template <typename T, template <typename> typename Cont>
            struct is_valid {};
    
            template <typename T, template <typename> typename Cont>
            struct chain;
    
            template <typename T, template <typename> typename Cont>
            struct chain {
                    using value_type_t = T;
                    using holder_t = Cont<value_type_t>;
    
                    chain()
                    {}
    
                    chain(holder_t&& value_)
                    : value(std::move(value_))
                    {}
    
                    template <typename Func>
                    constexpr auto otherwise(Func&& func) {
                            return chain<T, Cont>{std::move(func())};
                    }
    
                    template <typename Func>
                    constexpr auto with(Func&& func) -> chain<value_type_t, Cont> {
                            if (bool(value)) {
                                    return chain<value_type_t, Cont>{Cont<value_type_t>{func(*value)}};
                            }
                            else {
                                    return chain<value_type_t, Cont>{};
                            }
                    }
    
                    holder_t value;
            };
    
            template <typename T, template <typename> typename Cont>
            chain(Cont<T>&&) -> chain<T, Cont>;
    
            template <typename T, template <typename> typename Cont>
            struct use {
                    using value_type_t = T;
                    using holder_t = Cont<value_type_t>;
    
                    use(holder_t&& value)
                    : value(std::move(value))
                    {}
    
                    template <typename Func>
                    constexpr auto with(Func&& func) -> chain<value_type_t, Cont> {
                            if (is_valid<T, Cont>{}(value)) {
                                    return chain<value_type_t, Cont>{Cont<value_type_t>{func(*value)}};
                            }
                            else {
                                    return chain<value_type_t, Cont>{};
                            }
                    }
    
                    holder_t value;
            };
    
            template <typename T, template <typename> typename Cont>
            use(Cont<T>&&) -> use<T, Cont>;
            
    }
    
    namespace aim {
            template <typename T>
            struct is_valid<T, std::optional> {
                    constexpr bool operator()(std::optional<T> const& value) {
                            return bool(value);
                    }
            };
    }
    
    #include <iostream>
    #include <memory>
    
    int main() {
            {
                    std::optional<int> a;
    
                    aim::use(std::move(a)).with([](auto v) {
                            std::cout << v << '\n';
                            return 1;
                    }).otherwise([](){
                            std::cout << "it's none!\n";
                            return 2;
                    }).with([](auto v){
                            std::cout <<  v << '\n';
                            return 3;
                    });
            }
    }

    говно

    j123123, 06 Июля 2017

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

    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
    #include <iostream>
    #include <string>
    
    int main()
    {
    	std::cout << "Купи слона!" << std::endl;
    	
    	while(true)
      	{
        		std::string temp;
        		std::getline(std::cin, temp);
        		std::printf("Все говорят: \"%s\", а ты купи слона!\n", temp.c_str());
      	}
    }

    Когда не любишь 1c.

    Losyash1337, 28 Июня 2017

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

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    void DrawLine(Vec2Si32 a, Vec2Si32 b, Rgba color_a, Rgba color_b) { // https://pastebin.com/p26FvZdd
        Vec2Si32 ab = b - a;
        Vec2Si32 abs_ab(std::abs(ab.x), std::abs(ab.y));
        if (abs_ab.x >= abs_ab.y) {
            if (a.x > b.x) {
                DrawLine(b, a, color_b, color_a);
            } else {
                Sprite back = GetEngine()->GetBackbuffer();
                Vec2Si32 back_size = back.Size();
                if (ab.x == 0) {
                    if (a.x >= 0 && a.x < back_size.x &&
                            a.y >= 0 && a.y < back_size.y) {
                        back.RgbaData()[a.x + a.y * back.StridePixels()] = color_a;
                    }
                    return;
                }
                Si32 x1 = std::max(0, a.x);
                Si32 x2 = std::min(back_size.x - 1, b.x);
                Si32 y1 = a.y + ab.y * (x1 - a.x) / ab.x;
                Si32 y2 = a.y + ab.y * (x2 - a.x) / ab.x;
                if (y1 < 0) {
                    if (y2 < 0) {
                        return;
                    }
                    // lower left -> upper right
                    y1 = 0;
                    x1 = a.x + ab.x * (y1 - a.y) / ab.y;
                    x1 = std::max(0, x1);
                } else if (y1 >= back_size.y) {
                    if (y2 >= back_size.y) {
                        return;
                    }
                    // upper left -> lower right
                    y1 = back_size.y - 1;
                    x1 = a.x + ab.x * (y1 - a.y) / ab.y;
                    x1 = std::max(0, x1);
                }
                if (y2 < 0) {
                    // upper left -> lower right
                    y2 = 0;
                    x2 = a.x + ab.x * (y2 - a.y) / ab.y;
                    x2 = std::min(back_size.x - 1, x2);
                } else if (y2 >= back_size.y) {
                    // lower left -> upper right
                    y2 = back_size.y - 1;
                    x2 = a.x + ab.x * (y2 - a.y) / ab.y;
                    x2 = std::min(back_size.x - 1, x2);
                }
                Vec4Si32 rgba_a(static_cast<Si32>(color_a.r),static_cast<Si32>(color_a.g),static_cast<Si32>(color_a.b),static_cast<Si32>(color_a.a));
                Vec4Si32 rgba_b(static_cast<Si32>(color_b.r),static_cast<Si32>(color_b.g),static_cast<Si32>(color_b.b),static_cast<Si32>(color_b.a));
                Vec4Si32 rgba_ab = rgba_b - rgba_a;
                Vec4Si32 rgba_1 = rgba_a + rgba_ab * (x1 - a.x) / ab.x;
                Vec4Si32 rgba_2 = rgba_a + rgba_ab * (x2 - a.x) / ab.x;
                Vec4Si32 rgba_12 = rgba_2 - rgba_1;
                if (x2 <= x1) {
                    if (x2 == x1) {
                        Rgba color(rgba_1.x, rgba_1.y, rgba_1.z, rgba_1.w);
                        back.RgbaData()[x1 + y1 * back.StridePixels()] = color;
                    }
                    return;
                }
                Vec4Si32 rgba_16 = rgba_1 * 65536;
                Vec4Si32 rgba_12_16 = rgba_12 * 65536;
                Vec4Si32 rgba_12_16_step = rgba_12_16 / (x2 - x1);
                Si32 y_16 = y1 * 65536;
                Si32 y12_16_step = ((y2 - y1) * 65536) / (x2 - x1);
                Si32 stride = back.StridePixels();
                for (Si32 x = x1; x <= x2; ++x) {
                    Rgba color(rgba_16.x >> 16,rgba_16.y >> 16,rgba_16.z >> 16,rgba_16.w >> 16);
                    back.RgbaData()[x + (y_16 >> 16) * stride] = color;
                    rgba_16 += rgba_12_16_step;
                    y_16 += y12_16_step;
                }
            }
        } else { // тут почти тоже самое
            if (a.y > b.y) {
                DrawLine(b, a, color_b, color_a);
            } else {
                Sprite back = GetEngine()->GetBackbuffer();
                Vec2Si32 back_size = back.Size();
                if (ab.y == 0) {
                    if (a.y >= 0 && a.y < back_size.y && a.x >= 0 && a.x < back_size.x) {
                        back.RgbaData()[a.x + a.y * back.StridePixels()] = color_a;
                    }
                    return;
                }
                Si32 y1 = std::max(0, a.y);
                Si32 y2 = std::min(back_size.y - 1, b.y);
                Si32 x1 = a.x + ab.x * (y1 - a.y) / ab.y;
                Si32 x2 = a.x + ab.x * (y2 - a.y) / ab.y;
                if (x1 < 0) {
                    if (x2 < 0) {
                        return;
                    }
                    // lower left -> upper right
                    x1 = 0;
                    y1 = a.y + ab.y * (x1 - a.x) / ab.x;
                    y1 = std::max(0, y1);
                } else if (x1 >= back_size.x) {
                    if (x2 >= back_size.x) {

    Взято отсюда https://github.com/FrostyMorning/arctic/blob/master/engine/easy.cpp
    https://pastebin.com/p26FvZdd

    cin, 22 Июня 2017

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

    −2

    1. 1
    throw new runtime_error

    https://github.com/search?l=C%2B%2B&q=%22throw+new+runtime_ error%22&type=Code&utf8=%E2%9C%93

    subaru, 11 Июня 2017

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

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    #include <iostream>
    #include <Windows.h>
    
    #define OCT_1 0
    #define OCT_2 12
    #define OCT_3 24
    #define OCT_4 36
    #define OCT_5 48
    #define OCT_6 60
    #define OCT_7 72
    #define OCT_8 84
    #define OCT_9 96
    
    #define NOTE_C 0
    #define NOTE_Ch 1
    #define NOTE_Db 1
    #define NOTE_D 2
    #define NOTE_Dh 3
    #define NOTE_Eb 3
    #define NOTE_E 4
    #define NOTE_F 5
    #define NOTE_Fh 6
    #define NOTE_Gb 6
    #define NOTE_G 7
    #define NOTE_Gh 8
    #define NOTE_Ab 8
    #define NOTE_A 9
    #define NOTE_Ah 10
    #define NOTE_Bb 10
    #define NOTE_B 11
    
    long double notes[200];
    
    #define TEMPO 100
    #define LEN1 (120000 / TEMPO)
    #define LEN2 (LEN1 / 2)
    #define LEN4 (LEN1 / 4)
    #define LEN8 (LEN1 / 8)
    #define LEN16 (LEN1 / 16)
    
    #define melody_len 28
    struct s {
    	int key, len;
    	s(int key, int len) {
    		this->key = key;
    		this->len = len;
    	}
    } melody[melody_len] = {
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_C, LEN4),
    	
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_C, LEN4),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_E, LEN4),
    	
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_D, LEN8),
    	s(OCT_4 + NOTE_D, LEN8),
    	
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_E, LEN4),
    };
    
    int main(int argc, char** argv) {
    	notes[0] = 32.7032;
    	for(int i = 1; i < 200; ++i)
    		notes[i] = notes[i - 1] * 1.05946309436;
    		
    	for(int i = 0; i < melody_len; ++i) {
    		int key = melody[i].key;
    		int len = melody[i].len;
    		
    		if(key < 0) Sleep(len);
    		else Beep(notes[key], len);
    	}
    	
    	return 0;
    }

    Дохуя мелодия... с 1 класса музыкалки...

    Losyash1337, 27 Мая 2017

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

    −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
    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
    for (int i = 0; i < WorkedVerts.count(); i++)
    	{
    		int R0 = (i + Offset0) % WorkedVerts.count();
    		int R1 = (i + Offset1) % WorkedVerts.count();
    		int R2 = (i + Offset2) % WorkedVerts.count();
    
    		XA << WorkedVerts.at(R0).Position;
    		XB << WorkedVerts.at(R1).Position;
    		XC << WorkedVerts.at(R2).Position;
    	}
    	PrepareDataPointers(XA, XB, XC);
    	Inset_Cuda(InputData0, InputData1, InputData2, OutputData, XA.count(), -Amount);
    
    	for (int x = 0; x < XA.count(); x++)
    	{
    		if (fabs(OutputData[x].x) < 0.0001f && fabs(OutputData[x].y) < 0.0001f && fabs(OutputData[x].z < 0.0001f))
    		{
    			int Start = x;
    			int Start1 = (x + (XA.count() - 1)) % XA.count();
    			QVector3D StartVec = QVector3D(OutputData[Start1].x, OutputData[Start1].y, OutputData[Start1].z);
    			QVector3D EndVec = StartVec;
    			int End = 0;
    			while (true)
    			{
    				End = Start++;
    				if (fabs(OutputData[End].x) > 0.0001f && fabs(OutputData[End].y) > 0.0001f && fabs(OutputData[End].z > 0.0001f))
    				{
    					EndVec = QVector3D(OutputData[End].x, OutputData[End].y, OutputData[End].z);
    					break;
    				}
    			}
    			QVector3D OffsetX0 = WorkedVerts.at(Start).Position - StartVec;
    			QVector3D OffsetX1 = WorkedVerts.at(End).Position - EndVec;
    			QVector3D Mid2 = OffsetX0 + (OffsetX1 - OffsetX0) * 0.5f;
    			OutputData[x].x = Mid2.x();
    			OutputData[x].y = Mid2.y();
    			OutputData[x].z = Mid2.z();
    		}
    	}
    	int VertsCounter = SharedVerts.count();
    	for (int i = 0; i < WorkedVerts.count(); i++)
    	{
    		SharedVertex NewVert;
    		int Count3 = WorkedVerts.count();
    		int index = (i + (Count3 - 1)) % Count3;
    		NewVert.Position = QVector3D(OutputData[index].x, OutputData[index].y, OutputData[index].z);
    		NewVert.Index = VertsCounter++;
    		SV2 << NewVert;
    	}

    Код нахождения копии контура вершин с оффсетом.

    IVK, 26 Мая 2017

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

    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
    #include <bits/stdc++.h> 
            
    using namespace std;
              
    int B[105], N, k, u, v, i, z;
    map<int, int> A;
            
    main()
    {
        for(cin >> N; cin >> k; B[i++] = k)
            ++A[k] > v ? v = A[u = k] :
                A[k] ^ v ?: u = min(u, k);
               
        for(; z < N; z++)
            B[z] == u || cout << B[z] << " ";
                                         
        while(v--) cout << u << " ";
    }

    Решение задачи из acmp, первое место по количеству символов, обогнав других участников на 30 и более символов.

    Обычное решение задачи, тех которые не участвовали у конке, количество символов от 600-700 символов, тут же 208 символов

    aat, 24 Мая 2017

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    template<typename T> FORCEINLINE typename std::enable_if<Is_CastToFloat<T>::value, UFloatStat*>::
      type Add(T &v ,const FStatInfo &Info=FStatInfo::Empty, bool Visible=true)
      {
        float vf=(float)v;
        auto r=_AddFloat(vf, Info, Visible);
        T vb=static_cast<T>(vf);
        if(vb!=v)
          v=vb;//const_cast<T&>(v)=vb;
        return r;
      }

    // Method for Enum, Integer types and bool

    antondoe, 24 Мая 2017

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