結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー m0ntBL4Nc
提出日時 2019-09-01 18:23:07
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 165 ms
コンパイル使用メモリ 38,464 KB
最終ジャッジ日時 2026-02-22 04:38:03
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
    int N;
    scanf("%d", &N);

    int numbers[N];

    char buffer[256];
    rewind(stdin);
    fgets(buffer, 256, stdin);

    char *p_buffer;
    p_buffer = strtok(buffer, " ");

    int numbersIndex = 0;
    while(p_buffer != NULL) {
        int number = atoi(p_buffer);
        numbers[numbersIndex++] = number;
        p_buffer = strtok(NULL, " ");
    }

    int sumNumbers = 0;
    for(int i=0; i<N; i++) {
        sumNumbers += numbers[i];
    }

    printf("%d\n", sumNumbers);

    return 0;
}
0