SkeptaProgrammer

Untitled

Sep 23rd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. // task_2.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
  2. //
  3. /*
  4.     ПРАВИЛЬНОСТЬ ВВЕДЁННЫХ СЛОВ ИСПОЛЬЗУЯ СЛОВАРЬ. УПОРЯДОЧЕННЫЙ ЛИНЕЙНЫЙ СПИСОК ПО ЗАГОТОВЛЕННОМУ ФАЙЛУ. еСЛИ НА 40% И БОЛЬШЕ СОВПАДАЕТ, ТО КОМП КОРРЕКТИРУЕТ
  5.     ИНАЧЕ ГОВОРИТ ШО ВСЁ НЕ ТО.
  6. */
  7.  
  8. #include "pch.h"
  9. #include <iostream>
  10. #include <string>
  11. #include <fstream>
  12. using namespace std;
  13.  
  14. struct List
  15. {
  16.     string data;
  17.     List *next;
  18. };
  19.  
  20.  
  21.  
  22. void Print(List *list)
  23. {
  24.     List *p = list;
  25.     cout << "List:" << endl;
  26.     while (p)
  27.     {
  28.         cout << p->data << endl;
  29.         p = p->next;
  30.     }
  31.  
  32. }
  33. int main()
  34. {
  35.     setlocale(0, "");
  36.     ifstream file("C:\\Users\\Владимир\\source\\repos\\task_2\\dictionary.txt");
  37.     ///*
  38.     List *first = new List;
  39.     List *next = new List;
  40.     first->next = nullptr;
  41.     while (!file.eof())
  42.     {
  43.         if (first->next == nullptr)
  44.         {
  45.             file >> first->data;
  46.             first->next = next;
  47.         }
  48.         else
  49.         {
  50.             next->next = new List;
  51.             file >> next->data;
  52.             next = next->next;
  53.         }
  54.     }
  55.     if (file.eof())
  56.     next->next = nullptr;
  57.     Print(first);
  58.     //*/
  59.     cout << "Hello World!\n";
  60.     return 0;
  61. }
Add Comment
Please, Sign In to add comment