please convert the code to C language //C++ program to check if two arrays //are equal or not #include using namespace std; bool similar_array(vector arr1, vector arr2) { //create teo different hash table where for each key //the hash function is h(arr[i])=arr[i] //we will use stl map as hash table and //will keep frequency stored //so say two keys arr[0] and arr[5] are mapping to //the same location, then the location will have value 2 //instead of the keys itself //if two hash tables are exactly same then //we can say that our arrays are similar map hash1; map hash2; //for each number for (int i = 0, j = 0; i < arr1.size(); i++, j++) { hash1[arr1[i]]++; hash2[arr2[i]]++; } //now check whether hash tables are exactly same or not for (auto it = hash1.begin(), ij = hash2.begin(); it != hash1.end() && ij != hash2.end(); it++, ij++) { if (it->first != ij->first || it->second != ij->second) return false; } //so ans will be updated maxdiff return true; } int main() { int n, m; cout << "Enter number of elements for array1 & array2\n"; cin >> n; //arrays having equal sum vector arr1(n, 0); vector arr2(n, 0); cout << "Input the array elements\n"; for (int i = 0; i < n; i++) { cin >> arr1[i]; cin >> arr2[i]; } if (similar_array(arr1, arr2)) cout << "The arrys are equal"; else cout << "The arrys are not equal"; return 0; } Output:
please convert the code to C language
//C++ program to check if two arrays
//are equal or not
#include <bits/stdc++.h>
using namespace std;
bool similar_array(
{
//create teo different hash table where for each key
//the hash function is h(arr[i])=arr[i]
//we will use stl map as hash table and
//will keep frequency stored
//so say two keys arr[0] and arr[5] are mapping to
//the same location, then the location will have value 2
//instead of the keys itself
//if two hash tables are exactly same then
//we can say that our arrays are similar
map<int, int> hash1;
map<int, int> hash2;
//for each number
for (int i = 0, j = 0; i < arr1.size(); i++, j++) {
hash1[arr1[i]]++;
hash2[arr2[i]]++;
}
//now check whether hash tables are exactly same or not
for (auto it = hash1.begin(), ij = hash2.begin(); it != hash1.end() && ij != hash2.end(); it++, ij++) {
if (it->first != ij->first || it->second != ij->second)
return false;
}
//so ans will be updated maxdiff
return true;
}
int main()
{
int n, m;
cout << "Enter number of elements for array1 & array2\n";
cin >> n;
//arrays having equal sum
vector<int> arr1(n, 0);
vector<int> arr2(n, 0);
cout << "Input the array elements\n";
for (int i = 0; i < n; i++) {
cin >> arr1[i];
cin >> arr2[i];
}
if (similar_array(arr1, arr2))
cout << "The arrys are equal";
else
cout << "The arrys are not equal";
return 0;
}
Output:
![Enter number of elements for array1 & array2
6
Input the array elements
1 2 1 3 2 1
2 2 3 1 1 1
The arrys are equal](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F69aa193b-87a6-4ad2-b09f-af122462b6cb%2Fe7a6605c-39b0-4e82-b280-eb4e97ee6c2e%2Fl4lo81_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)