View difference between Paste ID: 6SApy80B and LYaV7ynW
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2
#include <fstream>
3
#include <vector>
4
using namespace std;
5
int main()
6
{
7
	ifstream fin("IN.txt");
8
	ofstream fout("OUT.txt");
9
	if (!fin.is_open())
10
		cout << "File cannot be opened!\n";
11
	else
12
	{
13
		int kolvo;
14
		fin >> kolvo;
15
		if (kolvo <= 20)
16
		{
17
			float buff[20];
18
			for (int i = 0; i<kolvo; ++i)
19
				fin >> buff[i];
20
			for (int i = 0; i < kolvo; i++)
21
				fout << buff[i] << " ";
22
			fout << endl;
23
			vector <float> vec_buff;
24
			for (int i = 0; i < kolvo; i++)
25
				for (int j = i + 1; j < kolvo; j++)
26
					if (buff[i] == buff[j])
27
						vec_buff.push_back(buff[i]);
28
			for (int i = 0; i < vec_buff.size(); i++)
29
				for (int j = i + 1; j < vec_buff.size(); j++)
30
					if (vec_buff[i] == vec_buff[j])
31
					{
32
						vec_buff.erase(vec_buff.begin() + j);
33
						j--;
34
					}
35
			fout << vec_buff.size() << endl;
36
			fin.close();
37
			fout.close();
38
		}
39
		else
40
			cout << "Number of elements must be under 21!!!!";
41
	}
42
	return 0;
43
}