結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー 猫吉
提出日時 2019-02-08 10:11:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 206 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 65,292 KB
最終ジャッジ日時 2025-01-06 20:50:30
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:13: warning: ‘sum’ may be used uninitialized [-Wmaybe-uninitialized]
   12 |         sum += i;
      |         ~~~~^~~~
main.cpp:8:10: note: ‘sum’ was declared here
    8 |     long sum;
      |          ^~~

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

int main() {
    int n,i;
    long sum;
    cin >> n;
    for (; n>0 ;n--) {
        cin >> i;
        sum += i;
    }
    cout << sum << "\n";
}
0