#include "stdafx.h"
#include
using namespace std;
#define ARRAY_ELEMNET_NUMBER 40
int GenerateArrayAndCalculateSum(int);
int _tmain(int argc, _TCHAR* argv[])
{
int xMax;
cout<<"Please input xMax:"<
cout<<"The sum of the array:\n"<
return 0;
}
int GenerateArrayAndCalculateSum(int xMax)
{
//Generate Array
int * Array = new int[ARRAY_ELEMNET_NUMBER];
for(int i=0;i
do{
randomNumber = rand();
}while(randomNumber>=xMax);
Array[i] = randomNumber;
cout<<"the %d"< }
//Get sum:
int sum =0;
for(int i=0;i
}
delete [] Array;
Array = NULL;
return sum;
}
//眼高手低可不好呀~
····················································生成40个不大于xMax的随机数很难吗?
数组求和很难吗?这都问人,烧饼