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

    +20

    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
    void __fastcall TfРѕrm1::SpeedButton1Click(TobjРµct *Sender)
    {
    SpeedButton1->Enabled=false;
     SpeedButton1->Caption=Edit1->Text;
     if(Edit1->Text=="X")
     Edit1->Text="0";
     else
     Edit1->Text="X";
     if(SpeedButton1->Caption=="X" && SpeedButton2->Caption=="X" && SpeedButton3->Caption=="X" ||
     SpeedButton4->Caption=="X" && SpeedButton5->Caption=="X" && SpeedButton6->Caption=="X" ||
     SpeedButton7->Caption=="X" && SpeedButton8->Caption=="X" && SpeedButton9->Caption=="X" ||
     SpeedButton1->Caption=="X" && SpeedButton4->Caption=="X" && SpeedButton7->Caption=="X" ||
      SpeedButton2->Caption=="X" && SpeedButton5->Caption=="X" && SpeedButton8->Caption=="X" ||
       SpeedButton3->Caption=="X" && SpeedButton6->Caption=="X" && SpeedButton9->Caption=="X" ||
        SpeedButton1->Caption=="X" && SpeedButton5->Caption=="X" && SpeedButton9->Caption=="X" ||
         SpeedButton3->Caption=="X" && SpeedButton5->Caption=="X" && SpeedButton7->Caption=="X")
    
      ShowMessage("Ea?a caeii?aia, e?anoeee auea?aee");
    
      else
       if(SpeedButton1->Caption=="0" && SpeedButton2->Caption=="0" && SpeedButton3->Caption=="0" ||
     SpeedButton4->Caption=="0" && SpeedButton5->Caption=="0" && SpeedButton6->Caption=="0" ||
     SpeedButton7->Caption=="0" && SpeedButton8->Caption=="0" && SpeedButton9->Caption=="0" ||
     SpeedButton1->Caption=="0" && SpeedButton4->Caption=="0" && SpeedButton7->Caption=="0" ||
      SpeedButton2->Caption=="0" && SpeedButton5->Caption=="0" && SpeedButton8->Caption=="0" ||
       SpeedButton3->Caption=="0" && SpeedButton6->Caption=="0" && SpeedButton9->Caption=="0" ||
        SpeedButton1->Caption=="0" && SpeedButton5->Caption=="0" && SpeedButton9->Caption=="0" ||
         SpeedButton3->Caption=="0" && SpeedButton5->Caption=="0" && SpeedButton7->Caption=="0")
      ShowMessage("Ea?a caeii?aia, iieeee auea?aee");
    
    }

    jQuery, 29 Октября 2012

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

    +18

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    template <class TBitMap, int MMCROffset>
    class TControllerMemoryMappedRegister: public TBaseControllerMemoryMappedRegister<MMCROffset>
    {
    public:
    	static void set(TBitMap::E Bit) { setBit(Bit); }
    	static void reset(TBitMap::E Bit) { resetBit(Bit); }
    };

    Говногость, 29 Октября 2012

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

    +15

    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
    #include <iostream>
    #include <cxxabi.h>
    #include <typeinfo>
    
    int main(void)
    {
       uint8_t i = 63;
       int  status;
    
       std::cout << i << std::endl;
    
       char *realname = abi::__cxa_demangle(typeid(i).name(), 0, 0, &status);
       std::cout << "Real type of uint8_t is: " << realname << std::endl;
       delete (realname);
    
       std::cout << (unsigned int)i << std::endl;
    
    return 0;
    }

    ...нативный 8bit-ый беззнаковый int.

    sayidandrtfm, 28 Октября 2012

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

    +16

    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 <functional>
    
    using namespace std;
    
    class O{};
    
    class foo
    {
    public:
       constexpr static auto anyGarbage = O(O(O(O())));//:Жаль, что написать auto anyGarbage = O(O(O(O()))); нельзя.
       O anyGarbage2 = O(O(O(O())));
       
    private:
       int var;
       
    public:
       std::function<void(int)> setter=[this](int s){(void)s;/*var=s;*/};
    };

    Я хочу написать свои property, принимающие лямбды в качестве параметра setter и getter. Как сделать friend лямбду?
    http://liveworkspace.org/code/39082e70108502c2e44c4fe6c5762d9a

    USB, 26 Октября 2012

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

    +30

    1. 1
    if( str[0] == '<' || str[1] == '?' || str[2] == 'x' || str[3] == 'm' || str[4] == 'l') {...}

    Проверка на xml-ность

    bazhenovc, 24 Октября 2012

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

    +25

    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
    template <typename T> struct Pool { static std::vector<T> data; };
    
    std::vector<tbphys::Body> Pool<tbphys::Body>::data;
    std::vector<Ball>         Pool<Ball>        ::data;
    std::vector<Wall>         Pool<Wall>        ::data;
    std::vector<Bat>          Pool<Bat>         ::data;
    std::vector<Brick>        Pool<Brick>       ::data;
    
    template <typename T, typename U> struct List
    {
    	typedef T Head;
    	typedef U Tail;
    };
    
    struct End {};
    
    typedef List<tbphys::Body, List<Brick, List<Bat, List<Ball, List<Wall, End> > > > > Components;
    typedef List<Brick, List<Bat, List<Ball, List<Wall, End> > > > DrawableComponents;
    typedef List<Brick, List<Ball, List<Bat, End> > > MovableComponents;
    
    const size_t badindex = size_t(-1);
    
    struct GameBody
    {
    	size_t self,body,bat,brick,wall,ball;
    
    	template <typename T> size_t& IndexOf ();
    	template <> size_t& IndexOf <tbphys::Body> () {return body;}
    	template <> size_t& IndexOf <Bat  >        () {return bat;}
    	template <> size_t& IndexOf <Brick>        () {return brick;}
    	template <> size_t& IndexOf <Wall >        () {return wall;}
    	template <> size_t& IndexOf <Ball >        () {return ball;}
    
    	template <typename T>
    	T& AddComponent ()
    	{
    		size_t index = Pool<T>::data.size();
    		Pool<T>::data.resize(index+1);
    		T& result = Pool<T>::data[index];
    
    		result.hostIndex = self;	
    		IndexOf<T>() = index;
    		return result;
    	}
    
    	template <typename T> void SetBadIndex ()
    	{
    		IndexOf<T::Head> () = badindex;
    		SetBadIndex<T::Tail> ();
    	}
    	template <> void SetBadIndex <End> () {}
    };

    Сколько тут говнопаттернов крестоблядского крестоязыка?

    TarasB, 22 Октября 2012

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

    +9

    1. 1
    http://ideone.com/vvkWO4

    Fai, 21 Октября 2012

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

    +28

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    const std::string cyrillic = "аАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяЯ";
    
    std::string cyrillic_toupper(std::string s)
    {
       if(cyrillic.find(s) == std::string::npos)
          throw std::runtime_error(std::string("cyrillic_toupper(): ") + "'" + s + "' is not cyrillic char");
    
       return cyrillic.substr(cyrillic.find(s) + 2, 2);
    }

    an0nym, 21 Октября 2012

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

    +21

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    int main()
    {
        unsigned int input[65536];
        int counter=0;
        while(scanf("%u", &(input[counter++])) != EOF);
        while (counter-- > 0) printf("%.4f\n", sqrt((double)(input[counter])));
        return 0;
    }

    Реализация задачи http://acm.timus.ru/problem.aspx?space=1&num=1001

    kganker, 19 Октября 2012

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

    +26

    1. 1
    2. 2
    3. 3
    4. 4
    std::RAII_File(fileName, moda, [&](std::IOHandle fHandle)
    {
       //...
    });

    Паrни. Что-за код мне достался? Какой наркоман это написал? У него же ЛГМ лямбда головного мозга.
    О std-инъекциях я даже молчу.

    LispGovno, 19 Октября 2012

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