結果

問題 No.1902 AC Ratio
ユーザー miraissanmiraissan
提出日時 2023-11-13 10:51:13
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 2,930 ms
コンパイル使用メモリ 246,324 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-13 10:51:18
合計ジャッジ時間 4,396 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:19:28: warning: 'mid' may be used uninitialized [-Wmaybe-uninitialized]
   19 |     kigou[1] = S.substr(mid+1);
      |                         ~~~^~
main.cpp:6:9: note: 'mid' was declared here
    6 |     int mid; //スラッシュの位置
      |         ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace  std;
int main(){
 array<string,2>kigou;
 string S;
    int mid; //スラッシュの位置
    float before;
    float after;
 cin >> S;

 for(int i=0; i<S.length();i++) {
    if(S[i]=='/') {
         mid = i;
        break;
    }
 }

    kigou[0] = S.substr(0,mid);
    kigou[1] = S.substr(mid+1);

     before = stof(kigou[0]);
     after  = stof(kigou[1]);

    float num = before / after;
    cout << num << endl;
    //cout << kigou[0]<< endl;

    //cout << kigou[1]<< endl;
/* kigou[]
 int A = atoi(S.c_str());
 int B = atoi(S.c_str());
 float num = A / B;
 cout << num << endl;*/
}
0