- 1
https://pastebin.com/pk5bB1Y4
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 4
0
https://pastebin.com/pk5bB1Y4
Я вам покушать принес. Задача кратко и четко объяснить человеку, почему лучше обмазаться дотнетом чем винапи. Пока решил написать группе что следующий факультатив (на котором я должен разбирать их портянки) отменяется, а там что-нибудь придумаю. Две крайности - (new EchoServer).start() и вот это, что ты будешь делать.
+3
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 раскрывает секреты односвязных списков.
0
#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
Хз что там за задание, какая-то долгая и муторная работа с текстом.
0
#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)
Взято из паблика втентакле, где собираются студни со своими неординарными решениями лабораторных. Задача была реализовать чтение-запись структур в файл/из файла, а также сортировку по убыванию/возрастанию одного из полей.