請問這樣的程式碼哪裡錯了?
#include<iostream>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int *a;
int *b;
b = new int[n+1];
a = new int[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
b[0] = 0;
for(int i=1;i<n+1;i++){
b[i] = b[i-1]+a[i-1];
//cout<<b[i]<<" ";
}
//cout<<'\n';
for(int i=0;i<m;i++){
int t,u;
cin>>t>>u;
cout<<b[u]-b[t-1]<<'\n';
}
delete []a;
delete []b;
}
請問這樣的程式碼哪裡錯了?
#include
using namespace std;int main(){
int n,m;
cin>>n>>m;
int *a;
int *b;
b = new int[n+1];
a = new int[n];
for(int i=0;i
cin>>a[i];
}
b[0] = 0;
for(int i=1;i
b[i] = b[i-1]+a[i-1];
//cout< }
//cout<<'\n';
for(int i=0;i
int t,u;
cin>>t>>u;
cout<
}
delete []a;
delete []b;
}
題目是多筆測資喔
請問這樣的程式碼哪裡錯了?
#include
using namespace std;int main(){
int n,m;
cin>>n>>m;
int *a;
int *b;
b = new int[n+1];
a = new int[n];
for(int i=0;i
cin>>a[i];
}
b[0] = 0;
for(int i=1;i
b[i] = b[i-1]+a[i-1];
//cout< }
//cout<<'\n';
for(int i=0;i
int t,u;
cin>>t>>u;
cout<
}
delete []a;
delete []b;
}題目是多筆測資喔
大感恩!!