Print Pretty

  • + 2 comments
        string integer = to_string(abs((int)B));
    
        cout << setw(0) << "0x" << hex << (int)A << endl;
        if (B > 0) {
            cout << setw(15 - (integer.length() + 3)) << setfill('_') << fixed << setprecision(2) << '+' << B << endl;
        } else {
            cout << setw(15) << setfill('_') << fixed << setprecision(2) << B << endl;
        }
        cout << setw(0) << scientific << setprecision(9) << C << endl;
        cout << endl;
    
        Here is my source code, but I can only pass case 1. I have no idea where the error is.