-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay_042.cpp
67 lines (55 loc) · 1.08 KB
/
Day_042.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
67
/**
*Problem Statement: a Program to check if two arrays are the same or not.
*Author: Kunal Kathpal (https://github.com/kunal-2002)
*/
#include <bits/stdc++.h>
using namespace std;
int sort(int arr[], int n){
int i, j;
for(i=0; i<n-1;i++){
for(j=0;j<n-i-1;j++){
if(arr[j]>arr[j+1]){
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
}
int compare(int arr1[], int arr2[], int n, int m){
sort(arr1, n);
sort(arr2, m);
int i;
for(i=0; i<n;i++){
if(arr1[i] != arr2[i]){
return 0;
}
}
return 1;
}
int main(){
cout<<"Enter number of test cases:\t";
int T;
cin>>T;
while(T--){
int n1, n2;
cout<<"Enter the size of first array:\n";
cin>>n1;
cout<<"Enter the size of second array:\n";
cin>>n2;
int arr1[n1];
int arr2[n2];
cout<<"Enter the first array elements:\n";
for(int i = 0; i<n1;i++)
cin>>arr1[i];
cout<<"Enter the second array elements:\n";
for(int j = 0; j<n2;j++)
cin>>arr2[j];
if(compare(arr1, arr2, n1, n2) == 0)
cout<<"Not Same";
else
cout<<"Same";
cout<<endl;
}
return 0;
}