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:

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter8: Arrays
Section: Chapter Questions
Problem 13RQ
icon
Related questions
Question

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(vector<int> arr1, vector<int> 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<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
Transcribed Image Text: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
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT