Check if mirror image of a number is same if displayed in seven segment display | C ++ Program to check if mirror image of a number is same if displayed in seven segment display ; Return " Yes " , if the mirror image of number is same as the given number Else return " No " ; Checking if the number contain only 0 , 1 , 8. ; Checking if the number is palindrome or not . ; If corresponding index is not equal . ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; string checkEqual ( string S ) { for ( int i = 0 ; i < S . size ( ) ; i ++ ) { if ( S [ i ] != '1' && S [ i ] != '0' && S [ i ] != '8' ) { return " No " ; } } int start = 0 , end = S . size ( ) - 1 ; while ( start < end ) { if ( S [ start ] != S [ end ] ) { return " No " ; } start ++ ; end -- ; } return " Yes " ; } int main ( ) { string S = "101" ; cout << checkEqual ( S ) << endl ; return 0 ; }