Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Mirror Inverse Program in c++

// C++ implementation of the approach
#include<bits/stdc++.h>
using namespace std;
 
// Function that returns true if
// the array is mirror-inverse
bool isMirrorInverse(int arr[], int n)
{
    for (int i = 0; i < n; i++)
    {
 
        // If condition fails for any element
        if (arr[arr[i]] != i)
            return false;
    }
 
    // Given array is mirror-inverse
    return true;
}
 
// Driver code
int main()
{
        int arr[] = { 1, 2, 3, 0 };
        int n = sizeof(arr)/sizeof(arr[0]);
        if (isMirrorInverse(arr,n))
            cout << "Yes";
        else
            cout << "No";
        return 0;
}
 
// This code is contributed by Rajput-Ji
Comment

PREVIOUS NEXT
Code Example
Cpp :: nmake.exe is not found in the windows 
Cpp :: cap phat dong mang 2 chieu trong c++ 
Cpp :: adding two dates using necessary member function in c++ 
Cpp :: triangle angle sum 
Cpp :: convert string to double arduino 
Cpp :: C++ float and double simple example 
Cpp :: convert c++ to c online 
Cpp :: argsort c++ 
Cpp :: string in int in cpp 
Cpp :: 10^18 data type in c++ 
Cpp :: linq select where string equals "String" 
Cpp :: I/O Redirection in C++ 
Cpp :: array di struct 
Cpp :: delete item from linked list in c++ 
Cpp :: Polycarp found a rectangular table consisting of n rows and m columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns": codeforces solution 
Cpp :: && in cpp 
Cpp :: assegnare valori in c++ 
Cpp :: hamming c++ 
Cpp :: Chef and the Wildcard Matching codechef solution in c++ 
Cpp :: static_cast 
Cpp :: hpp files 
Cpp :: how to change the default camera speed values opengl 
Cpp :: 136. Single Number leetcode solution in c++ 
Cpp :: C++ Function-style Casting 
Cpp :: leetcode 36 c++ 
Cpp :: query for rmq using sqrt decomposition 
Cpp :: boost filesystem get filename without exetention from path 
Cpp :: columntransformer onehotencoder 
Cpp :: map update field elixir 
Cpp :: multilevel inheritance in c++ private method 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =