3 solutions

  • 1
    @ 2023-3-31 21:55:57

    用个sum储存和,枚举每一个元素然后累加就好了。

    #include<iostream>
    #define int long long
    using namespace std;
    int n,a,sum;
    signed main(){
    	cin>>n;
    	for(int i=1;i<=n;i++)cin>>a,sum+=a;
    	cout<<sum;
    	return 0;
    }
    

    Information

    ID
    6760
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    # Submissions
    350
    Accepted
    114
    Uploaded By