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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#include <iostream>
#include <ctime>
using namespace std;
void sortarray(double B[], int s){
int j=0;
double temp=0.0;
while (j<s){
int k = j+1;
while (k<s){
if(B[k]<B[j]){
temp = B[j];
B[j]=B[k];
B[k]=temp;
}
k++;
}
j++;
}
}
void randomVariables(double C[], int S, int M, int N){
srand (time(0));
int l=0;
double A=0.0;
while (l<S){
A = (rand ()% M)-N;
C[l] = A;
l++;
}
}
void printarray (double * A, int K){
int i=0;
double X=0.0;
while (i<K){
X=*(A+(i*8));
cout<<X<<' ';
i++;
}
return;
}
int main () {
int g=0;
int h=0;
int n;
int m=0;
double a=0.0;
double *x;
double b=0.0;
double *y;
cout<<"please enter the size of the array of abscissas"<<endl;
cin>>n;
cout<<"please enter the size of the array of ordinates"<<endl;
cin>>m;
x = new double [n];
y = new double [m];
randomVariables (x, n, 101, 0);
randomVariables (y, m,101, 0);
sortarray(x,n);
sortarray(y,m);
x = new double [n+n-2];
y = new double [m+n-2];
sortarray (x, (n+n-2));
printarray (x ,n);
cout<<'\n';
printarray (y ,m);
cout<<'\n';
printarray (x, (n+n-2));
cout<<'\n';
printarray (y, (m+n-2));
cout<<'\n';
delete x;
x = NULL;
delete y;
y = NULL;
delete x;
x=NULL;
delete y;
y=NULL;
return 0;
}
|