Print Pretty

Sort by

recency

|

177 Discussions

|

  • + 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 */
    }``
    
  • + 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 */
    }
    
  • + 0 comments

    WHAT'S WRONG WITH MY CODE?

    #include <iomanip>
    #include <iostream>
    #include <string>
    #include <vector>
    using namespace std;
    
    int main()
    {
        int number_test_cases;
        cin >> number_test_cases;
    
        for (int i = 0; i < number_test_cases; i++)
        {
            long double A, B, C;
            cin >> A >> B >> C;
    
            cout << std::showbase << std::hex << static_cast<long long int>(A) << endl;
    
            cout << std::noshowbase << std::dec << std::setw(15) << std::setfill('_') << std::fixed << std::setprecision(2) << std::right << showpos << B << endl;
    
        cout << std::noshowbase << std::dec << std::uppercase << std::scientific << std::setprecision(9) << noshowpos << C << endl;
    }
    

    }

  • + 0 comments

    I think the test cases are faulty.

  • + 0 comments

    This is actually problematic. Works with certain commands but fails when done step by step because of rounding errors in the test cases (sometimes 0.5 is rounded up and sometimes down).