wtorek, 7 czerwca 2022

Sum of sines (C++)

 #include <iostream>

#include <math.h>

#include <stdlib.h>

#include <time.h>


#define ss 8

using namespace std;


double y1(double b, double c)

{

return sin(b)+sin(c);

}

double y2(double b, double c)

{

double r;

r=2*sin(0.5*(b+c))*cos(0.5*(c-b));

return r;

}

double date[ss]={15.00,30.0,45.00,60.00,90.00,120.00,150.00,180.00};


double a1[ss],a2[ss];



int main(int argc, char **argv)

{

int k1,k2;

srand(time(NULL));

    for(int i=0;i<ss;i++)

    {

k1=rand()%ss;k2=rand()%ss;

a1[i]=y1(date[k1],date[k2]);

a2[i]=y2(date[k1],date[k2]);

cout<<a1[i]<<" ---- "<<a2[i]<<endl;

}


return 0;

}