Print Pretty

  • + 0 comments

    my answers are matched with test cases but can't passed the test cases

    include

    include

    using namespace std;

    int main() { int T; cin >> T; cout << setiosflags(ios::uppercase); cout << setw(0xf) << internal; while(T--) { double A; cin >> A; double B; cin >> B; double C; cin >> C; int integer=A; int devident=integer;//100 int devisor=16; string hexa=""; string tempString=""; int length=0; int rem;
    while(devident) {
    int temp=devident/devisor; rem=devident%devisor; devident=temp; if(rem<10){ tempString=48+rem; hexa=tempString+hexa; } else{ tempString=87+rem; hexa=tempString+hexa;

            }
    
    
    
        }
        cout<<setw(0);
        cout<<"0x";
        cout << hexa <<endl;
        int in=B;
        double decimal=B-in;
        int third=(decimal*1000);
        third=third%10;
        int temp=decimal*100;
        if(temp==0)
        {   
    
            decimal=0.01;
        }
        if(third>=5)
        {
            temp++;
        }
        else if(temp<10)
        {  
            decimal=temp*0.001;
        }
        else{
            decimal=temp*0.01;
        }
        B=decimal+in;
        string prefix="";
        while(in>0)
        {
            in=in/10;
            length++;
            prefix+="_";
        }
            for(int i=0;i<11-length*2;i++)
            {
                prefix+="_";
            }
    
    
    
        if(B>0)
        {
            prefix+="+";
            cout<<prefix<<fixed<< setprecision(2)<<B<<endl;
    
        }
        else{
            prefix+="-"; 
              cout <<prefix<<fixed << setprecision(2)<<B<<endl;
        }
        ;
    
    
        cout <<scientific<<setprecision(9)<<C<<endl;  
        /* Enter your code here */
    }