CONVERT 문제 오답원인이 궁금하네요.

  • newcomet
    newcomet

    아래와 같이 구현했는데 오답의 원인을 찾지 못하고 있습니다.

    using namespace std;

    int main() {
    int testCase = 0;

    cin >> testCase;
    int cnt = 0;
    while (testCase--) {
        string units;
        float num;
    
        cin >> num;
        cin >> units;
    
        cout << ++cnt << " ";

    // cout.precision(4);
    // cout.setf(std::ios::fixed, std::ios::floatfield);

    if (units.compare("Kg") == 0) {
            cout << std::fixed << std::setprecision(4) << num * 2.2046 << " lb"<< endl;
        } else if (units.compare("lb") == 0) {
            cout << std::fixed << std::setprecision(4) << num * 0.4536 << " Kg" << endl;
        } else if (units.compare("l") == 0) {
            cout << std::fixed << std::setprecision(4) << num * 0.2642 << " g" << endl;
        } else if (units.compare("g") == 0) {
            cout << std::fixed << std::setprecision(4) << num * 3.7854 << " l"<< endl;
        }
    }

    }


    8년 전
1개의 댓글이 있습니다.
  • park_sk90
    park_sk90

    K가 소 문 자 인 듯


    8년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.