#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
bool is_Minus()
{
int value;
value=rand()%2;
if(value==1)
return true;
else
return false;
}
int plus_Minus(int value)
{
if(is_Minus())
{
value=value*-1;
}
return value;
}
int sum_Q1(int a, int b)
{
int sum;
sum=(a*a)+(2*a*b)+(b*b);
return sum;
}
int minus_Q1(int a, int b)
{
int minus;
minus=(a-b)*(a+b);
return minus;
}
int sum_Q2(int a, int b)
{
int sum;
sum=(a*a)-(2*a*b)+(b*b);
return sum;
}
int minus_Q3(int a, int b)
{
int minus;
minus=(a-b)*((a*a)+(a*b)+(b*b));
return minus;
}
int sum_Q3(int a, int b)
{
int sum;
sum=(a+b)*((a*a)-(a*b)+(b*b));
return sum;
}
int sum_Q3_2(int a, int b)
{
int sum;
sum=(a*a*a)+(3*(a*a)*b)+(3*a*(b*b))+(b*b*b);
return sum;
}
int minus_Q3_2(int a, int b)
{
int minus;
minus=(a*a*a)-(3*(a*a)*b)+(3*a*(b*b))-(b*b*b);
return minus;
}
int *results,*a_v,*b_v;
int main(int argc, char **argv)
{
srand(time(NULL));
int i;
results=new int[7];
a_v=new int[7];
b_v=new int[7];
for(i=0;i<7;i++)
{
a_v[i]=plus_Minus(rand()%20+1);
b_v[i]=plus_Minus(rand()%20+1);
}
results[0]=sum_Q1(a_v[0],b_v[0]);
results[1]=minus_Q1(a_v[1],b_v[1]);
results[2]=sum_Q2(a_v[2],b_v[2]);
results[3]=minus_Q3(a_v[3],b_v[3]);
results[4]=sum_Q3(a_v[4],b_v[4]);
results[5]=sum_Q3_2(a_v[5],b_v[5]);
results[6]=minus_Q3_2(a_v[6],b_v[6]);
for(i=0;i<7;i++)
{
cout<<a_v[i]<<" "<<b_v[i]<<" = "<<results[i]<<endl;
}
delete b_v;
delete a_v;
delete results;
return 0;
}
Brak komentarzy:
Prześlij komentarz