1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <iostream>
using namespace std;
int displayArrays(int x[], int y[], int z[], int length);
int fillArrays(int x[],int y[],int length);
int SAXPY(int x[], int y[],int z[], int A, int length);
int main()
{
const int size = 698817;
const int A = 3;
int x[size];
int y[size];
int z[size];
fillArrays(x,y,size);
SAXPY(x,y,z,A,size);
displayArrays(x,y,z,size);
return 0;
}
int displayArrays(int x[], int y[], int z[], int length)
{
int i;
for (i=0;i<length;i++)
{
cout << x[i] << " " << y[i] << " " << z[i] << endl;
}
return 0;
}
int fillArrays(int x[],int y[],int length)
{
int i;
srand (time(NULL) - 1350000000);
for (i=0;i<length;i++)
{
x[i]=rand()%10;
y[i]=rand()%10;
}
return 0;
}
int SAXPY(int x[], int y[],int z[], int A, int length)
{
int i;
for (i=0;i<length;i++)
{
z[i] = (A * x[i]) + y[i];
}
return 0;
}
|