[Problem]
求n个数的和
[Solution]
#include <iostream> using namespace std; int main(){ // definition int n, sum = 0, data; cin >> n; for(int i = 0; i < n; ++i){ cin >> data; sum += data; } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ // definition int n, sum = 0, data; cin >> n; for(int i = 0; i < n; ++i){ cin >> data; sum += data; } cout << sum << endl; return 0; }