Skip to content

Commit

Permalink
Chapter 4. Simple dictionary.
Browse files Browse the repository at this point in the history
  • Loading branch information
Grandmother committed Apr 12, 2016
1 parent 0115823 commit af8e02e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions chapter 4/dictionary.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

#define IOERR 74

int main()
{
vector<string> dictionary;

cout << "Enter some words to dictionary:\n";
for ( string temp ; cin >> temp; )
{
dictionary.push_back(temp);
}

sort(dictionary.begin(), dictionary.end());
cout << "\n\nWords in dictionary:\n";
for ( int i = 0; i < dictionary.size(); ++i )
{
if ( i == 0 || dictionary[i-1] != dictionary[i] )
{
cout << dictionary[i] << '\n';
}
}
return 0;
}

0 comments on commit af8e02e

Please sign in to comment.