问题出在哪里啦,输入数字之后,系统提示Run-Time Check Failure #3 - The variable 'a' is being used without being initialized.
//其中给定整数存放在数组List[]中,正整数N是数组元素个数。该函数须返回N个List[]元素的和。
#include <iostream>
#include <stdlib.h>
using namespace std;
int Sum(int *List,int n);
int Sum(int *List,int n){
int i,n,sum=0;
for(i=0;i<n;i++){
sum+=List[i];
}
return sum;
}
int main(){
int i,n,*List;
cout<<"请输入n:"<<endl;
cin>>n;
for(i=0;i<n;i++){
cout<<"请输入数组元素:"<<endl;
cin>>List[i];
cout<<Sum(List,n)<<endl;
}
system("pause");
return 0;
}