题解 | #牛牛的新数组求和#
牛牛的新数组求和
https://www.nowcoder.com/practice/bdd2cd6638f849cfa06216198e8eb967
#include <cstdio> #include <iostream> using namespace std; int cal(int array[], int n) { int result = 0; for (int i = 0; i < n; i++) { result += array[i]; } return result; } int main() { int n; scanf("%d", &n); int arr[n]; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } int result = cal(arr, n); printf("%d", result); return 0; }