Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
struct list { list(char _elem = 0, list *_next = NULL) : elem(_elem), next(_next) { } char elem; list *next; }; void print(list *l); void unique(list *l); char input(const char *path, list *l); int main() { setlocale(0, ""); list *S = new list(); input("symbols.txt", S); unique(S); print(S); return 0 * _getch(); } char input(const char *path, list *l) { FILE *stream = NULL; fopen_s(&stream, path, "r"); if (stream) { list *p = l, *t = p; // Считываем все символы из файла. for ( ; fscanf_s(stream, "%c", &p->elem, 1) != EOF; p->next = new list(), t = p, p = p->next); delete p; t = t->next = NULL; fclose(stream); return 0; } else { perror("Завершение работы программы"); return -1; } } void unique(list *l) { for (list *q = new list(0, l); q && q->next; q = q->next) { int dup_count = 0; for (list *t = q->next; t->next; t = t->next) // Поиск всех дубликатов. { if (t->next->elem == q->next->elem) // Нашелся дубликат. { dup_count++; list *w = t->next->next; delete t->next; t->next = w; } } if (dup_count) { list *w = q->next->next; delete q->next; if (w) *(q->next) = *w; else q->next = NULL; } } } void print(list *l) { printf_s("Результат работы программы: \n"); for (list *p = l; p; p = p->next) printf_s("%c", p->elem); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)