Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- int main()
- {
- ifstream fin("IN.txt");
- ofstream fout("OUT.txt");
- if (!fin.is_open())
- cout << "File cannot be opened!\n";
- else
- {
- int kolvo;
- fin >> kolvo;
- if (kolvo <= 20)
- {
- float buff[20];
- for (int i = 0; i<kolvo; ++i)
- fin >> buff[i];
- for (int i = 0; i < kolvo; i++)
- fout << buff[i] << " ";
- fout << endl;
- vector <float> vec_buff;
- for (int i = 0; i < kolvo; i++)
- for (int j = i + 1; j < kolvo; j++)
- if (buff[i] == buff[j])
- vec_buff.push_back(buff[i]);
- for (int i = 0; i < vec_buff.size(); i++)
- for (int j = i + 1; j < vec_buff.size(); j++)
- if (vec_buff[i] == vec_buff[j])
- {
- vec_buff.erase(vec_buff.begin() + j);
- j--;
- }
- fout << vec_buff.size() << endl;
- fin.close();
- fout.close();
- }
- else
- cout << "Number of elements must be under 21!!!!";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement