中秋节摆了一天,感觉畏难情绪一直困扰着我,要好好调制状态才行。
#include<iostream>
#include<vector>
using namespace std;
int main(){
int n = 0;
cin >> n;
vector<int> sum(n, 0);
for(int i = 0; i < n; ++i){
int num;
cin >> num;
if(i == 0) sum[0] = num;
else sum[i] = sum[i -1] + num;
}
int start, end;
while(cin >> start >> end){
if(start == 0){
cout << sum[end] << endl;
}else{
cout << sum[end] - sum[start -1] << endl;
}
}
return 0;
}
标签:58,int,sum,笔试,cin,start,num,第九期 From: https://www.cnblogs.com/llllmz/p/18417482