Mirror World

Imagine a world inside mirror, where everything becomes reverse. Left hand becomes right hand, right…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

Is it necessary to print 001 as 001?

Yes, print it as 001.

pls give me some test case

but 423 is not smller than 395 in our world

int main ()
{
    unsigned int M,N;
    int i, T;
    scanf("%d",&T);
    for(i=1;i<=N;i++){
        scanf("%u",&M);
        scanf("%u",&N);
        if(M<N){
        printf("%u > %u",M,N);

    }else if(M>N){
        printf("%u < %u",M,N);

    }else{
        printf("%u = %u",M,N);
    }

   }
    return 0;
}

what is wrong in this code??
for mirror project.

#include <stdio.h>
#include <math.h>

int main()
{
          int n, reversedNumber = 0, remainder;

    printf("Enter an integer: ");
    scanf("%d", &n);

    while(n != 0)
    {
        remainder = n%10;
        reversedNumber = reversedNumber*10 + remainder;
        n /= 10;
    }

    printf("Reversed Number = %d", reversedNumber);

  unsigned int M,N;
    int i, T;
    scanf("%d",&T);
    for(i=1;i<=N;i++){
        scanf("%u",&M);
        scanf("%u",&N);
        if(M<N){
        printf("%u > %u",M,N);

    }else if(M>N){
        printf("%u < %u",M,N);

    }else{
        printf("%u = %u",M,N);
    }

   }
    return 0;
}

what is the problem??

what is the orbolem in my code

#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
 int T,c=0;
long int m,n,p,q,r,s,k,l,a,b;
    cin >> T;
    for(c=1;c<=T;c++){
    cin >> m >> n;
    p=m/100;
    r=m%10;
    k=99*(p-r);
    a=m-k;
    q=n/100;
    s=n%10;
    l=99*(q-s);
    b=n-l;
    if(a==b){
        cout <<setw(3)<<setfill('0')<<m <<" = "<<setw(3)<<setfill('0')<< n << endl;
    }
    else if(a>=b){
        cout <<setw(3)<<setfill('0')<<m <<" > "<<setw(3)<<setfill('0')<< n << endl;
    }
    else if(a<=b) {
        cout <<setw(3)<<setfill('0')<<m <<" < "<<setw(3)<<setfill('0')<< n << endl;
    } 
        }
    return 0;
    
}

@EL_Drago Each number can have up to 500 digits. You can read such large numbers into long long ints.

423 is smaller number than 395 both in our world and mirror world.
what is it !!!

if i just reverse it and compare whats the problem?

ok if i reverse it and compare there is an invalid case like
10000000000 1 they are equal ,but it will show 10000000000<1
so we have to do extra work to handle these tai zeroes!

In the sample test case it is given that 423 = 423;
but reversed 423 is 324 which is less than 423 (in our world)
I couldnt figure out what the problem is , please help me with this.

Why it’s saying strrev is not found in liabrery…@hrj265

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    long long int b, c, d,g,h;
    char e[999],f[999];
    cin>>a;
    for(b=0; b<a; b++)
    {
        cin>>e>>f;
        g=stoi(e);
        h=stoi(f);
        strrev(e);
        strrev(f);
        c=stoi(e);
        d=stoi(f);
        if(c>d)
        {
            cout<<g<<" > "<<h<<endl;
        }
        else if(c<d)
        {
            cout<<g<<" < "<<h<<endl;
        }
        else if(c==d)
        {
            cout<<g<<" = "<<h<<endl;
        }
    }
}

Actually strrev(str) is a C function defined in the header file string.h in C. You cannot include this in a C++ program. Yes, there are alternatives to this in C++, its called reverse which is defined under the header file algorithm(#include)

1 Like