Write a program that accepts from keyboard integer value which stands for the # of data sets of random
integer each in the range [5, 10] and outputs all data sets in the elements, and the set of data that results in the larger sum.
Here is the code I have so far not sure what to add but I know I am missing something.
#include <iostream>
#include <cmath>
#include <iomanip>
double random (unsigned int & seed);
void print_data_set(int a[]);
int sum_of_data(int a[]);
void copy_sets(int a[], int b[]);
void set_up_data(int a[]);
const int SIZE=10;
int a[SIZE], maxarray[SIZE];
int i,j,k;
int sum, maxsum;
unsigned int seed;
using namespace std;
int main()
{
cout<<"Enter Number of Sets You Want: ";
cin>>i;
for (i=1; i<k; ++i)
{
set_up_data(a);
sum=sum_of_data(a);
if (sum>maxsum)
maxsum=sum;
}
return maxsum;
}
void set_up_data(int a[])
{
for (int i=0; i<SIZE; ++i)
a[i]=int (5+6*random(seed));
}
int sum_of_data(int a[])
{
for (j=1; j<10; ++i)
{
a[j]=int (5+6*random(seed));
sum =sum+ a[j];
}
return sum;
}
double random (unsigned int & seed)
{
const int MODULUS =15749;
const int MULTIPLIER=69069;
const int INCREMENT=1;
seed=((MULTIPLIER*seed)+ INCREMENT)% MODULUS;
return double (seed)/double (MODULUS);
}
void copy_sets(int a[], int b[])
{
for (int i=0; i<SIZE; ++i)
a[i]=b[i];
}
void print_data_set(int a[])
{
for (i=1; i<SIZE; ++i)
{
cout<<setw(3)<<a[i];
if (i%10==0)
cout<<i<<endl;
}
}
Thank You for Helping.

New Topic/Question
Reply



MultiQuote





|