結果
問題 |
No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
|
ユーザー |
![]() |
提出日時 | 2018-08-26 22:31:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 473 bytes |
コンパイル時間 | 119 ms |
コンパイル使用メモリ | 22,016 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 04:01:00 |
合計ジャッジ時間 | 1,192 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%ld",&a); | ~~~~~^~~~~~~~~~
ソースコード
// N個の数値データが空白区切で入力される その合計を求める #include<stdio.h> int main(void){ int N; //データ数 int i; long A[500000],a; //整数データ long sum = 0; //合計 scanf("%d",&N); for(i = 0; i < N; i++){ scanf("%ld",&a); A[i] = a; sum += a; } printf("%ld\n",sum); //小数点以下がない場合は整数で表示 %g // 今回の場合は、intよりも多くの字数扱えるlong intを使う return 0; }