Advertisement
Ermolaxe

Список однонаправленный(ОСНОВА)

Jun 16th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. #include "list.cpp"
  8.  
  9. ifstream fin("input.txt");
  10. ofstream fout("output.txt");
  11.  
  12. int main()
  13. {
  14.     List <int> list;
  15.     int value;
  16.     while (fin >> value)
  17.     {
  18.         list.Insert(list.GetLength() + 1, value);
  19.     }
  20.     fout << "Исходный список:";
  21.     list.Print();
  22.  
  23.     int i = 1;
  24.     while (i + 1 <= list.GetLength())
  25.     {
  26.         if (list.Get(i) == list.Get(i + 1)) list.Remove(i);
  27.         else  i++;
  28.     }
  29.  
  30.     fout << "Измененный список:";
  31.     list.Print();
  32.     return 0;
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement