-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram 2.cpp
66 lines (66 loc) · 990 Bytes
/
Program 2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<iostream>
#include<fstream>
#include<sstream>
using namespace std;
int main()
{
int number[100];
int unrepeated[50];
string line;
int n;
int i=0;
ifstream myfile("Numbers");
if(myfile.is_open())
{
while(getline(myfile,line))
{
// cout<<line<<endl;
}
istringstream is (line);
while(is >> n)
{
number[i]=n;
i++;
}
int size= i--;
int k=0,f=0;
for (int i=0;i<size;i++)
{
for(int j=0;j<size;j++)
{
if(i==j)
{
continue;
}
if(number[i]==number[j])
{
k++;
}
}
if(k==0)
{
unrepeated[f]=number[i];
f++;
}
k=0;
}
int unrepeated_size=f--;
ofstream unrepeatedfile ("unRepeated_Numers");
if(unrepeatedfile.is_open())
{
for(int i=0;i<unrepeated_size;i++)
{
unrepeatedfile<<unrepeated[i]<<" ";
}
}
for(int i=0;i<unrepeated_size;i++)
{
cout<<unrepeated[i]<<" ";
}
}
else
{
cout<<"Open the File, Please";
}
return 0;
}