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

    Всего: 4

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

    0

    1. 1
    https://pastebin.com/pk5bB1Y4

    Я вам покушать принес. Задача кратко и четко объяснить человеку, почему лучше обмазаться дотнетом чем винапи. Пока решил написать группе что следующий факультатив (на котором я должен разбирать их портянки) отменяется, а там что-нибудь придумаю. Две крайности - (new EchoServer).start() и вот это, что ты будешь делать.

    Fluttie, 18 Октября 2017

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

    +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
    bool  Object::DeleteDouble(void* data)
        {
            Element* rc = Head;
            BANKCLIENT* asd = (BANKCLIENT*)rc->Data;
            int dbl;
            Element* rc1 = Head;
            BANKCLIENT* asd1 = (BANKCLIENT*)rc1->Data;
            while ((rc != NULL) && (rc->Data != data))
            {
                asd = (BANKCLIENT*)rc->Data;
                dbl = asd->NumScore;
                while ((rc1 != NULL) && (rc1->Data != data))
                {
                    asd1 = (BANKCLIENT*)rc1->Data;
                    if (dbl == asd1->NumScore)
                    {
                        std::cout << "Дублирующийся элемент удалён" << std::endl;
                        Delete(rc1);
                        goto flag;
                    }
                }
            }
        flag:
            system("pause");
            return rc;
        }

    Некая svetlana.kotik раскрывает секреты односвязных списков.

    Fluttie, 20 Мая 2016

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

    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 <fstream>
    #include <iostream>
    #include <string>
    #include <list>
    #include <vector>
    #include <set>
    #include <algorithm>
    
    std::vector<std::string> split(const std::string &text, char sep) {
    	std::vector<std::string> tokens;
    
    	std::size_t start = 0, end = 0;
    	while ((end = text.find(sep, start)) != std::string::npos) {
    		std::string temp = text.substr(start, end - start);
    		if (temp != "") tokens.push_back(temp);
    		start = end + 1;
    	}
    	std::string temp = text.substr(start);
    	if (temp != "") tokens.push_back(temp);
    	return tokens;
    
    }
    
    void ReplaceStringInPlace(std::string& subject, const std::string& search,
    	const std::string& replace) {
    	size_t pos = 0;
    	while ((pos = subject.find(search, pos)) != std::string::npos) {
    		subject.replace(pos, search.length(), replace);
    		pos += replace.length();
    	}
    }
    
    
    using namespace std;
    using std::vector;
    using std::list;
    using std::set;
    
    int main()
    {
    	setlocale(LC_ALL, "rus");
    
    	// задание 1
    	string buff;
    	list<string> allText;
    
    	//задание 2
    	list<string> chap1;
    	list<string> chap2;
    	list<string> chap3;
    	list<string> chap4;
    	list<string> chap5;
    	string::size_type n;
    	int chapter = 0;
    
    	//задание 5
    
    	vector<string> textWord;
    	vector<string> rezult;
    	vector <string>::size_type kolvotext=0;
    	set<string>Unique_word;
    	vector<string>::iterator j;
    
    	ifstream fin("D:\\lab_c__5_text.txt");
    	if (!fin.is_open())
    		cout << "Файл не может быть открыт!\n";
    	else {
    
    		while (getline(fin, buff)) {
    			allText.push_back(buff);
    			//разбиение по главам
    			n = buff.find("CHAPTER");
    			if (n == 0) {
    				chapter++;
    			}
    			if (chapter == 1) {
    				chap1.push_back(buff);
    			}
    			else if (chapter == 2) {
    				chap2.push_back(buff);
    			}
    			else if (chapter == 3) {
    				chap3.push_back(buff);
    			}
    			else if (chapter == 4) {
    				chap4.push_back(buff);
    			}
    			else if (chapter == 5) {
    				chap5.push_back(buff);
    			}
    			//разбиение по словам
    			
    			ReplaceStringInPlace(buff, ".", "");
    			ReplaceStringInPlace(buff, "!", "");
    			ReplaceStringInPlace(buff, "?", "");
    			ReplaceStringInPlace(buff, ",", "");
    			ReplaceStringInPlace(buff, ";", "");
    			ReplaceStringInPlace(buff, ":", "");

    http://cpp.sh/3nlm6
    Хз что там за задание, какая-то долгая и муторная работа с текстом.

    Fluttie, 12 Мая 2016

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

    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
    #include <iostream>
    #include <string>
    #include <fstream>
    #include <locale>
    #include <windows.h>
    #include <conio.h>
    #include <cstdlib>
    
    using namespace std;
    
    struct Book
    {
    string author;
    string name;
    string year;
    };
    
    struct toolstruct
    {
    string filename;
    ifstream file_for_read;
    ofstream file_for_write;
    unsigned int struct_cnt = 0;
    HANDLE stdouthandle = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD pos;
    Book * shelfptr;
    };
    
    enum SSORT_TYPE
    {
    SSORT_INC = 1,
    SSORT_DEC = -1
    };
    
    void Display(toolstruct*);
    void Edit(toolstruct*);
    void Sort(toolstruct*, SSORT_TYPE);
    void Write(toolstruct*);
    
    int main()
    {
    
    setlocale(LC_ALL, "Russian");
    
    toolstruct ftool;
    char buff;
    unsigned int i = 0;
    
    do
    {
    cout<<"Введите имя каталога:"<<endl;
    getline(cin, ftool.filename);
    ftool.file_for_read.open(ftool.filename.c_str(), ios_base::in);
    }while(!ftool.file_for_read.is_open());
    
    
    while(!ftool.file_for_read.eof() && ftool.struct_cnt<20)
       {
       ftool.file_for_read>>buff;
       if(buff=='~'){ftool.struct_cnt++;}
       };
    ftool.shelfptr = new Book[ftool.struct_cnt];
    ftool.file_for_read.clear();
    ftool.file_for_read.seekg(0);
    ftool.shelfptr = new Book[ftool.struct_cnt];
    do
       {
       ftool.file_for_read>>buff;
       if(buff=='~')
          {
          getline(ftool.file_for_read, ftool.shelfptr[i].author);
          getline(ftool.file_for_read, ftool.shelfptr[i].name);
          getline(ftool.file_for_read, ftool.shelfptr[i].year);
          i++;
          }
       }while(!ftool.file_for_read.eof());
    ftool.file_for_read.close();
    Display(&ftool);
    }
    
    void Display(toolstruct* ts)
    {
    //void (*callback_ptr)(toolstruct*) = Display;
    system("cls");
    cout<<"Содержимое файла "<<ts->filename<<":"<<endl
        <<"   Автор            "<<"Название            "<<"Год публикации"<<endl;
    if(ts->struct_cnt != 0)
    {
    for(unsigned short j = 0; j<ts->struct_cnt; j++)
    {
    ts->pos.X = 0;
    ts->pos.Y = j+2;
    SetConsoleCursorPosition(ts->stdouthandle, ts->pos);
    cout<<j+1<<". ";
    if(ts->shelfptr[j].author.length()<=20)
        {cout<<ts->shelfptr[j].author;}
    else{cout<<ts->shelfptr[j].author.substr(0,16)+"...";}
    ts->pos.X = 20;
    SetConsoleCursorPosition(ts->stdouthandle, ts->pos);
    if(ts->shelfptr[j].name.length()<=20)

    Взято из паблика втентакле, где собираются студни со своими неординарными решениями лабораторных. Задача была реализовать чтение-запись структур в файл/из файла, а также сортировку по убыванию/возрастанию одного из полей.

    Fluttie, 10 Мая 2016

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