結果

問題 No.656 ゴルフ
ユーザー RightRight
提出日時 2018-03-06 05:03:15
言語 C++11
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 453 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 31,232 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 12:17:15
合計ジャッジ時間 944 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     scanf("%d",&score);
      |     ~~~~~^~~~~~~~~~~~~
main.cpp:16:22: warning: ‘scoreSum’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |             scoreSum += 10;
      |             ~~~~~~~~~^~~~~

ソースコード

diff #

#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