Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <string>
- using namespace std;
- const int LENGTH = 1000;
- void readData(string *words)
- {
- string tmp;
- ifstream file;
- file.open("NAPIS.TXT");
- for (int i = 0; i < LENGTH; i++) {
- file >> words[i];
- }
- file.close();
- }
- void findAllRepeatingWords(string *words)
- {
- string repeated;
- int i = 0;
- while (i < LENGTH) {
- repeated = "";
- while (words[i++].compare(words[i]) == 0) {
- repeated = words[i];
- }
- if (!repeated.empty()) {
- cout << repeated << endl;
- }
- }
- }
- int main()
- {
- string words[LENGTH];
- readData(words);
- sort(words, words + LENGTH);
- findAllRepeatingWords(words);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement