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

    Всего: 11

  2. Си / Говнокод #14707

    +140

    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
    #include<stdio.h>
    int main()
    {FILE*f1,*f2;
    f1=fopen("input.txt","r");
    f2=fopen("output.txt","w");
    int i,j,k,l,n,m,l1,m1;
    int a[100000]={0};
    int b[100]={0},b1[100]={0};
    fscanf(f1,"%d%d",&n,&k);
    for(i=0;i<n;i++)
    {fscanf(f1,"%d",&a[i]);
    if (i==0) b[(a[i]%k+k)%k]=1;
    else {for(j=0;j<k;j++)
    if(b[j]==1) {b1[(a[i]%k+j+k)%k]=1; b1[(j-a[i]%k+k)%k]=1;}
    for(j=0;j<k;j++)
    {b[j]=b1[j]; b1[j]=0;}}}
    if (b[0]==1) fprintf(f2,"Divisible");
    else fprintf(f2,"Not divisible");
    fclose(f1);
    fclose(f2);
    return 0;}

    Динамический алгоритм. работа с остатками. тестировщик прожевал и выдал максимум:)

    Sauron, 20 Февраля 2014

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

    +11

    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
    /// Represents the model of a Writer document.
    class SW_DLLPUBLIC SwDoc :
        public IInterface,
        public IDocumentSettingAccess,
        public IDocumentDeviceAccess,
        public IDocumentRedlineAccess,
        public IDocumentLinksAdministration,
        public IDocumentFieldsAccess,
        public IDocumentContentOperations,
        public IDocumentStylePoolAccess,
        public IDocumentLineNumberAccess,
        public IDocumentStatistics,
        public IDocumentState,
        public IDocumentDrawModelAccess,
        public IDocumentLayoutAccess,
        public IDocumentTimerAccess,
        public IDocumentChartDataProviderAccess,
        public IDocumentListItems,
        public IDocumentOutlineNodes,
        public IDocumentListsAccess,
        public IDocumentExternalData
    {
    ...

    Вот это монстрище!

    http://opengrok.libreoffice.org/xref/core/sw/inc/doc.hxx

    Sauron, 23 Декабря 2013

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

    +77

    1. 1
    float tlen = sqrtf(top[0]*top[0]+top[1]*top[1]+top[2]*top[2]);

    Всё в мире тлен и безысходность. В том числе и код.

    Sauron, 10 Августа 2013

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

    +151

    1. 1
    return *reinterpret_cast<ChatUnitList*>(&m_contacts); //black magic

    Действительно черная магия... Хотя работает, но я не уверен, что на всех платформах

    Sauron, 28 Июня 2010

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

    +59.6

    1. 1
    *reinterpret_cast<int *>(&showFlags) = behavior.value("showFlags", 0xfffffff);

    Немножко эзотерики, нашел в нашем проекте, писалось видимо в 3 часа ночи.

    Sauron, 18 Января 2010

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

    +144.8

    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
    __inline BOOL
    SearchOneDirectory(
                      IN  LPSTR Directory,
                      IN  LPSTR FileToFind,
                      IN  LPSTR SourceFullName,
                      IN  LPSTR SourceFilePart,
                      OUT PBOOL FoundInTree
                      )
    {
        //
        // This was way too slow. Just say we didn't find the file.
        //
        *FoundInTree = FALSE;
        return(TRUE);
    }

    Оптимизация by Microsoft. Шедевр из утёкших в 2004 году исходников Windows, заставило посмеятся, веселые у Микрософта заглушки

    Sauron, 16 Января 2010

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

    +55.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
    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
    #define constuserColor "usercolor"
    #define consttagColor "tagcolor"
    #define constmsgColor "idcolor"
    #define constQcolor "quotecolor"
    #define constLcolor "linkcolor"
    #define constUbold "userbold"
    #define constTbold "tagbold"
    #define constMbold "idbold"
    #define constQbold "quotebold"
    #define constLbold "linkbold"
    #define constUitalic "useritalic"
    #define constTitalic "tagitalic"
    #define constMitalic "iditalic"
    #define constQitalic "quoteitalic"
    #define constLitalic "linkitalic"
    #define constUunderline "userunderline"
    #define constTunderline "tagunderline"
    #define constMunderline "idunderline"
    #define constQunderline "quoteunderline"
    #define constLunderline "linkunderline"
    #define constIdAsResource "idAsResource"
    #define constShowPhoto "showphoto"
    #define constShowAvatars "showavatars"
    #define constWorkInGroupchat "workingroupchat"
    #define constVersion "0.9.9"
    
    class JuickPlugin : public QObject, public PsiPlugin, public EventFilter, public OptionAccessor, public ActiveTabAccessor,
        public StanzaFilter, public ApplicationInfoAccessor
    {
            Q_OBJECT
            Q_INTERFACES(PsiPlugin EventFilter OptionAccessor ActiveTabAccessor StanzaFilter ApplicationInfoAccessor)
    
    public:
            JuickPlugin();
            virtual QString name() const;
            virtual QString shortName() const;
            virtual QString version() const;
            virtual QWidget* options();
            virtual bool enable();
            virtual bool disable();
            virtual void applyOptions();
            virtual void restoreOptions();
            virtual bool processEvent(int account, QDomElement& e);
            virtual bool processMessage(int account, const QString& fromJid, const QString& body, const QString& subject);
            // OptionAccessor
            virtual void setOptionAccessingHost(OptionAccessingHost* host);
            virtual void optionChanged(const QString& option);
            //ActiveTabAccessor
            virtual void setActiveTabAccessingHost(ActiveTabAccessingHost* host);
            //ApplicationInfoAccessor
            virtual void setApplicationInfoAccessingHost(ApplicationInfoAccessingHost* host);
    
            virtual bool incomingStanza(int account, const QDomElement& stanza);
            void elementFromString(QDomElement& body,QDomDocument e, QString& msg, QString jid, QString resource = "");
            void nl2br(QDomElement& body,QDomDocument e, QString msg);
            void addPlus(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
            void addSubscribe(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
            void addHttpLink(QDomElement& body,QDomDocument e, QString msg);
            void addTagLink(QDomElement& body,QDomDocument e, QString tag, QString jid);
            void addUserLink(QDomElement& body,QDomDocument e, QString nick, QString altText, QString pattern, QString jid);
            void addMessageId(QDomElement& body,QDomDocument e, QString mId, QString altText,QString pattern, QString jid, QString resource = "");
            void addUnsubscribe(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
            void addDelete(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
            void addFavorite(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");

    Краткость - сестра таланта... Только видимо авторы этого чуда эту пословицу не знают.
    Да и количество непонятных макросов нам тоже намекает.
    Ну и конечно же необходимость в таком страшном множественном наследовании с возможностью рандомных побочных эффектов тоже намекает нам о говноархитектуре. В общем не зря авторы Psi решили начать писать новый клиент.

    Sauron, 01 Января 2010

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

    +59.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    //и теперь шлём запрос письма
                        reply = QString("<iq type='get' from='%1' to='%2' id='mail-request-%3'>"\
                            "<query xmlns='google:mail:notify' %4 %5/></iq>")
                                .arg(from)
                                .arg(to)
                                .arg(id)
                                .arg((lastCheck.value(QString("%1").arg(account),"")=="")?QString(""):QString("newer-than-time='%1'").arg(lastCheck.value(QString("%1").arg(account))))
                                .arg((lastTid.value(QString("%1").arg(account),"")=="")?QString(""):QString("newer-than-tid='%1'").arg(lastTid.value(QString("%1").arg(account))));
                        stanzaSender->sendStanza(account, reply);

    Раскопано в недрах плагинов к psi:
    Особенно радует шедевральная конвертация int'а в строку при помощи QString("%1").arg(account),"")
    Плюс ко всему комменты на русском в интернациональном проекте это немножко моветон

    Sauron, 29 Декабря 2009

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

    +54.4

    1. 1
    2. 2
    ConfigEntry::Ptr generateConfigEntry (const QVariant &val);
    QVariant genetateQVariant(const ConfigEntry::Ptr& entry);

    Страшно представить, и эта опечатка месяц пролежала в основном дереве исходников, хорошо хоть приватная функция

    Sauron, 01 Октября 2009

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

    +100.1

    1. 1
    ping -n 5 localhost > nul

    К сожалению в Windows не предусмотрено никаких штатных команд для организации задержки, поэтому для того, чтобы в скрипте реализовать задержку в n секунд, например чтобы дождаться пока процесс завершится и освободит ресурс, приходится или качать/писать сторонние утилиты или прибегать к подобной чёрной магии.

    Sauron, 09 Сентября 2009

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