-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathUncommon_elements.cpp
More file actions
61 lines (31 loc) · 803 Bytes
/
Copy pathUncommon_elements.cpp
File metadata and controls
61 lines (31 loc) · 803 Bytes
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
#include <iostream>
using namespace std;
int main() {
int len1 = 5, len2 = 4;
char str1[len1] = "afbde", str2[len2] = "wabq";
cout << "Uncommon Elements :" <<endl;
//loop to calculate str1- str2
for(int i = 0; i < len1; i++) {
for(int j = 0; j < len2; j++) {
if(str1[i] == str2[j])
break;
//when the end of string is reached
else if(j == len2-1) {
cout << str1[i] << endl;
break;
}
}
}
//loop to calculate str2- str1
for(int i = 0; i < len2; i++) {
for(int j = 0; j < len1; j++) {
if(str2[i] == str1[j])
break;
else if(j == len1-1) {
cout << str2[i] << endl;
break;
}
}
}
return 0;
}