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

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

    +73

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    private static class Errors extends ArrayList<String> {
    	private static final long serialVersionUID = 1L;
    }
    
    private static class Notices extends ArrayList<String> {
    	private static final long serialVersionUID = 1L;
    }

    две большие разницы

    Lure Of Chaos, 11 Апреля 2014

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

    +74

    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
    private static class MyStatefulActor extends DefaultActor {
          protected void act() {
            loop(new Runnable() {
              public void run() {
                react(new MessagingRunnable<String>(this) {
                  protected void doRun(final String msg) {
                    System.out.println("Stage #0: " + msg);
                    react(new MessagingRunnable<Double>() {
                      protected void doRun(final Double msg) {
                        System.out.println("  Stage #1: " + msg);
                        react(new MessagingRunnable<List<Integer>>() {
                          protected void doRun(final List<Integer> msg) {
                            System.out.println("    Stage #2: " + msg + "\n");
                          }
                      });
                    }
                  });
                }
              });
            }
          });
        }
      }
    }

    laMer007, 03 Апреля 2014

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

    +5

    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
    #include "iostream"
    using namespace std;
    void main ()
    {
    setlocale(LC_ALL,"Russian"); //Поддержка киррилицы
    
    float A1,A2,A3,A4,A5;  
    int N;
    int i;
    cout<<"Введите количество выступлений"<<endl;
    cin>>N;   //Вводим кол-во выступлений
    for(i=0;i<N;i++)  //Вводим массив
    {cout<<"Введите оценки за выступление"<<endl;
    cout<<"Введите оценку 1"<<endl;
    cin>>A1;
    cout<<"Введите оценку 2"<<endl;
    cin>>A2;
    cout<<"Введите оценку 3"<<endl;
    cin>>A3;
    cout<<"Введите оценку 4"<<endl;
    cin>>A4;
    cout<<"Введите оценку 5"<<endl;
    cin>>A5;
    
    if(A1>A2&&A1>A3&&A1>A4&&A1>A5) {cout<<A1;}  
    else if (A2>A1&&A2>A3&&A2>A4&&A2>A5) {cout<<"Максимальная оценка = "<<A2<<endl; }
    else if (A3>A1&&A3>A2&&A3>A4&&A3>A5) {cout<<"Максимальная оценка = "<<A3<<endl; }
    else if (A4>A1&&A4>A2&&A4>A3&&A4>A5) {cout<<"Максимальная оценка = "<<A4<<endl; }
    else if (A5>A1&&A5>A2&&A5>A3&&A5>A4) {cout<<"Максимальная оценка = "<<A5<<endl; }
    
    }
    }

    ЗАДАЧА
    Пожалуйста помогите составить для задачи на с++
    Я решаю задачи, но блок схемы строить не могу

    С ответов Гугла.
    http://otvety.google.ru/otvety/thread?tid=5bd43c242dce51f8

    gost, 25 Марта 2014

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

    +72

    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
    public boolean fastItemEquals(ItemStack st, ItemStack nd) {
            if(nd == null) return false;
            if(st.hashCode() != nd.hashCode()) return false;
            if(st.getType() != nd.getType()) return false;
            if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
            if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
            if(st.getItemMeta().getLore().size() != nd.getItemMeta().getLore().size()) return false;
            final List<String> 
                    lst = st.getItemMeta().getLore(),
                    lnd = nd.getItemMeta().getLore();
            for(int i = 0 ; i < st.getItemMeta().getLore().size() ; i++)
                if(!lst.get(i).equals(lnd.get(i))) return false;
            
            //return st.isSimilar(nd);
            return true;
        }
        
        public void fastItemRemove(Inventory inv, ItemStack st) {
            for(int i = 0 ; i < inv.getContents().length ; i++)
                if(fastItemEquals(st, inv.getContents()[i])) inv.clear(i); 
        }

    DiaLight, 15 Марта 2014

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

    +124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    @set /p d=<%0
    %d:~0,5%a=%d:~0,5%
    %a%c=%d:~9,1%
    %a%b%c%%d:~4,1%&%a%i%c%%d:~0,1%&%a%k%c%&%a%l%c%&%a%m%c%&%a%n%c%&%a%o%c%&%a%p%c%&%a%q%c%&%a%r%c%&%a%s%c%&%a%t%c%&%a%u%c%&%a%v%c%&%a%w%c%&%a%x%c%&%a%y%c%&%a%z%c%
    %k%c%l%o%m%l%n%o%o%r%b%1%p%a%q%&%i%m%r%o%s%d%t%e%b%c%u%o%v%n%b%c%w%o%x%l%y%s%c%1%z%4%b%l%k%i%l%n%m%e%n%s%c%4%o%&%a%f%c%п%p%&%a%g%c%«%q%&%a%h%c%Ѓ%r%&%a%j%c%Д%s%&%a%e%c%!%t%&%u%t%v%i%w%t%x%l%y%e%b%.
    %i%e%k%c%t%h%s%o%b%%b%Ъ%j%%j%%j%%j%%j%%j%%j%%j%%j%ї%r%&%i%e%q%c%p%h%o%o%b%%b%і%b%%b%%h%%g%%f%%b%%e%%b%%b%і%n%&%i%e%m%c%l%h%k%o%b%%b%А%j%%j%%j%%j%%j%%j%%j%%j%%j%Щ%b%&%v%p%o%a%y%u%x%s%p%e%u%>%q%n%k%u%m%l%o%

    Должно быть запущено на русскоязычной Windows, сохраните в .bat файл, а на концах строчек (6 строк) не должно быть лишних пробелов!

    Ссылка на зипованную версию:
    http://klimaleksus.narod.ru/Files/C/fuck.zip

    aleksusklim, 11 Марта 2014

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

    +37

    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
    int hamming(int i, int j, vector<state>& net) //returns Hamming distance between i and j nodes
    {
    	int res = 0;
    	if (net[i].nodes[0] != net[j].nodes[0])
    	{
    		res++;
    	}
    	if (net[i].nodes[1] != net[j].nodes[1])
    	{
    		res++;
    	}
    	if (net[i].nodes[2] != net[j].nodes[2])
    	{
    		res++;
    	}
    	if (net[i].nodes[3] != net[j].nodes[3])
    	{
    		res++;
    	}
    	if (net[i].nodes[4] != net[j].nodes[4])
    	{
    		res++;
    	}
    	if (net[i].nodes[5] != net[j].nodes[5])
    	{
    		res++;
    	}
    	if (net[i].nodes[6] != net[j].nodes[6])
    	{
    		res++;
    	}
    	if (net[i].nodes[7] != net[j].nodes[7])
    	{
    		res++;
    	}
    	if (net[i].nodes[8] != net[j].nodes[8])
    	{
    		res++;
    	}
    	if (net[i].nodes[9] != net[j].nodes[9])
    	{
    		res++;
    	}
    	if (net[i].nodes[10] != net[j].nodes[10])
    	{
    		res++;
    	}
    	if (net[i].nodes[11] != net[j].nodes[11])
    	{
    		res++;
    	}
    	if (net[i].nodes[12] != net[j].nodes[12])
    	{
    		res++;
    	}
    	return res;
    }

    Человеку срочно нужно узнать про существование циклов.

    galarr, 08 Марта 2014

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

    +36

    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
    #include <iostream>
    
    class StaticClassData {
      int *pointer, value;
    
    public:
      StaticClassData(): pointer(&value) {}
      
      void add(int i) {
        std::cout << "Hello, this is " << this << std::endl;
        value = i;
        std::cout << "I'm fine" << std::endl;
        *pointer = i;
        std::cout << "You never read this text" << std::endl;
      }
    };
    
    class SomeClass {
      struct StaticConstructor {
        StaticConstructor(){ storage.add(1); }
      };
      
      static StaticConstructor constructor;
      static StaticClassData storage;
    };
    
    SomeClass::StaticConstructor SomeClass::constructor;
    StaticClassData SomeClass::storage;
    
    int main(){}

    Долго думал, с какого хрена программа падает на заполнении static поля в "статическом конструкторе". Поле вроде бы есть, но толку от этого мало.
    http://ideone.com/Ux14ep - из раздела ub.govnokod.ru или как выстрелить себе в ногу до выполнения main.

    1024--, 01 Марта 2014

    Комментарии (9)
  9. PHP / Говнокод #15205

    +175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(!$item["region"])
    	$item["region"] = "Москва";
    
    	if($item["region"])
    	$text = str_replace('<option>'.$item["region"].'</option>', '<option value="'.$item["region"].'" selected>'.$item["region"].'</option>', $text);

    Гениальнейшая простановка selected для выбранного option в форме

    kindofbear, 27 Февраля 2014

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

    +143

    1. 1
    2. 2
    if (medicalRecords == null)
        new List<MedicalRecordDispatchingInfoViewModel>();

    Просто сделай мне лист

    Vadimyan, 26 Февраля 2014

    Комментарии (9)
  11. PHP / Говнокод #14942

    +152

    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
    ...
    ## $config['components'] - массив компонентов(>25) для Yii
    foreach ($config['components'] as $name => $component) {
        if ($name != 'db') {
            unset($config['components'][$name]);
        }
    }
    ...
    
    # потом был баг фикс 
    foreach ($config['components'] as $name => $component) {
        if ($name != 'db' && $name != 'db_stats') {
            unset($config['components'][$name]);
        }
    }

    Сделал один из наших программистов, потом другой добавил свое, и уже я , с утра, в безсознательном состоянии, хотел было добавить ещё условие " && $name != 'format'" , но увидев результат, в голове бзынкнуло - WTF I AM DOING!!!
    cделал так
    $config['components'] = array_intersect_key($config['components'], array('db'=>1, 'db_stats'=>1, 'format' => 1));

    xakki, 25 Февраля 2014

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