結果

問題 No.656 ゴルフ
コンテスト
ユーザー Right
提出日時 2018-03-06 05:03:15
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 453 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 200 ms
コンパイル使用メモリ 50,432 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-04 12:30:37
合計ジャッジ時間 774 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:16:22: warning: 'scoreSum' may be used uninitialized [-Wmaybe-uninitialized]
   16 |             scoreSum += 10;
      |             ~~~~~~~~~^~~~~
main.cpp:5:19: note: 'scoreSum' was declared here
    5 |     int i,j,score,scoreSum,scoreArray[9];
      |                   ^~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
#include <math.h>

int main(void) {
    int i,j,score,scoreSum,scoreArray[9];
    double power;
    scanf("%d",&score);
    for (i = 0; i < 9; i++) {
        power = pow(10,i);
        scoreArray[i] = (int)(score/power)%10;
    }
    for (j = 0; j < 9; j++) {
        if (scoreArray[j] != 0) {
        scoreSum += scoreArray[j];
        }else {
            scoreSum += 10;
        }
    }
    printf("%d\n",scoreSum);
    return 0;
}
0