sobota, 23 kwietnia 2022

Trigonometric - continue (C++)

 #include <iostream>

#include <math.h>

#include <fstream>

#define a 8


using namespace std;



double date[a]={0.00,30.00,45.00,60.00,90.00,180.00,270.00,360.00};


double f_Rad(double value)

{

return (value*3.14159265359)/180.00;

}

double msin[a],mcos[a],mtg[a],mctg[a];


int main(int argc, char **argv)

{

int i;

for(i=0;i<a;i++)

{

msin[i]=sin(f_Rad(date[i]));

mcos[i]=cos(f_Rad(date[i]));

mtg[i]=msin[i]/mcos[i];

mctg[i]=1.00/mtg[i];

}

fstream file("table.txt",ios::out);

if(file.good())

{

file<<"sin: 0,30,45,60,90,180,270,360\n";

for(i=0;i<a;i++)

{

file<<msin[i]<<"  ";

}

file<<"\n";

file<<"cos: 0,30,45,60,90,180,270,360\n";

for(i=0;i<a;i++)

{

file<<mcos[i]<<"  ";

}

file<<"\n";

file<<"tg: 0,30,45,60,90,180,270,360\n";

for(i=0;i<a;i++)

{

file<<mtg[i]<<"  ";

}

file<<"\n";

file<<"ctg: 0,30,45,60,90,180,270,360\n";

for(i=0;i<a;i++)

{

file<<mctg[i]<<"  ";

}

file<<"\n";

file.close();

}

return 0;

}


czwartek, 21 kwietnia 2022

Trigonometrict function (C++ Builder)

 


void __fastcall TForm1::TrackBar1Change(TObject *Sender)

{

 int x;

 double y,y1;

 x=TrackBar1->Position;

 Label1->Caption=IntToStr(x);

 y=(1.00*x);

 y1=y*(M_PI/180.00);

 Label2->Caption="sin: "+FloatToStrF(sin(y),ffGeneral,2,2);

 Label3->Caption="cos: "+FloatToStrF(cos(y),ffGeneral,2,2);

 Label4->Caption="tg: "+FloatToStrF(sin(y)/cos(y),ffGeneral,2,2);

 Label5->Caption="ctg:"+FloatToStrF(1.00/(sin(y)/cos(y)),ffGeneral,2,2);

 Label6->Caption="sin: (rad)  "+FloatToStrF(sin(y1),ffGeneral,2,2);

 Label7->Caption="cos: (rad)  "+FloatToStrF(cos(y1),ffGeneral,2,2);

 Label8->Caption="tg:  (rad)  "+FloatToStrF(sin(y1)/cos(y1),ffGeneral,2,2);

 Label9->Caption="ctg: (rad)  "+FloatToStrF(1.00/(sin(y1)/cos(y1)),ffGeneral,2,2);



}

piątek, 1 kwietnia 2022

Writing a text file into Word (C++ Builder)

 void __fastcall TForm1::Button1Click(TObject *Sender)

{

 fstream file;

 char* path="C:\\Users\\user\\winInstal.txt";

 Variant wordExe, wordValues;


 file.open(path, ios::in );

 if( file.good() )

    {

        string text;

        wordExe=Variant::GetActiveObject("Word.Application");

        wordValues=wordExe.OlePropertyGet("Selection");


        while( !file.eof() )

        {


            getline( file,text );

            wordValues.OlePropertySet("Text",text.c_str());

            wordValues.OleProcedure("Select");

            wordValues=Unassigned;

            wordExe=Unassigned;



        }


        file.close();


     }


     else

    ShowMessage("You can't open file");

}