TopCoder

User's AC Ratio

100.0% (1/1)

Submission's AC Ratio

50.0% (1/2)

Tags

Description

小黃瓜是偷懶學院的必修課「最佳化睡眠」的大助教,他想要算所有學生的分數加總是多少。作為小黃瓜的朋友,你決定幫他解決這個問題。

請在程式碼最前面引入標頭檔 lib0624.h,並實作以下功能:

  • void sum (int *arr[])
    • arr 是一個指標陣列,每個指標指向一個 int,最後以 NULL 指標結尾。
    • 請把每個指標指向的 int 加總起來輸出。

注意此題不需要任何的輸入,否則將會發生不可預期的結果。

如果不確定該如何進行,可以參考以下的程式碼進行修改:

#include "lib0624.h"

void sum (int *arr[])
{
    // your code goes here

    // output the result
}

Input Format

數字的加總保證在 int 範圍內。

Output Format

請輸出一個數字,代表陣列的總和。

Sample Input 1

5
2 1 4 5 3

Sample Output 1

15

Hints

測試用標頭檔
這裡提供一份本地測試用的標頭檔,你可以將其複製下來存檔成 lib0624.h#include "lib0624.h" 做使用。但請注意,這只是測試用的標頭檔,一些與解題無關的行為將會與 judge 上的有所不同,因此請不要嘗試任何與解題無關的行為,很可能會導致各種不可預期的後果。

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0 範例測資 0
2 0~6 無額外限制 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 524288 65536 1 2
1 1000 524288 65536 2
2 1000 524288 65536 2
3 1000 524288 65536 2
4 1000 524288 65536 2
5 1000 524288 65536 2
6 1000 524288 65536 2