Last active
August 29, 2015 14:06
-
-
Save Evshved/89c7bbbf5a9acafec44b to your computer and use it in GitHub Desktop.
Lab#1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--------------------------------------------------------------------------- | |
Application | |
//--------------------------------------------------------------------------- | |
//The standard C libraries | |
#include <vcl.h> | |
#pragma hdrstop | |
#include "Paradigm.h" | |
#include "math.h" | |
//--------------------------------------------------------------------------- | |
#pragma package(smart_init) | |
#pragma resource "*.dfm" | |
TForm1 *Form1; | |
//--------------------------------------------------------------------------- | |
__fastcall TForm1::TForm1(TComponent* Owner) | |
: TForm(Owner) | |
{ | |
Edit1->Text="6,251"; | |
Edit2->Text="0,827"; | |
Edit3->Text="25,001"; | |
Memo1->Clear(); | |
} | |
//--------------------------------------------------------------------------- | |
void __fastcall TForm1::Button1Click(TObject *Sender) | |
{ | |
double x,y,z,subexp1,subexp2,subexp3,subexp4,subexp5,res; | |
if (TryStrToFloat(Edit1->Text,x) && TryStrToFloat(Edit2->Text,y) && TryStrToFloat(Edit3->Text,z) && x!=0) | |
{ | |
Memo1->Lines->Add(" X= "+FloatToStr(x)+" Y= "+FloatToStr(y)+" Z= "+FloatToStr(z)); | |
subexp1=pow(y,pow(fabs(x),1./3)); | |
subexp2=pow(cos(y),3); | |
subexp3=fabs(x-y); | |
subexp4=1+pow(sin(z),2)/sqrt(x+y); | |
//++d; | |
subexp5=exp(abs(x-y))+x/2; | |
res=subexp1+subexp2*subexp3*subexp4/subexp5; | |
Memo1->Lines->Add("Result="+FloatToStr(res)); | |
} | |
else | |
{ | |
Memo1->Lines->Add("Error"); | |
} | |
} | |
//Console | |
//--------------------------------------------------------------------------- | |
#pragma hdrstop | |
//--------------------------------------------------------------------------- | |
#pragma argsused | |
#include <stdio.h> | |
#include <conio.h> | |
#include <math.h> | |
#include <stdlib.h> | |
#include <classes.hpp> | |
int main(int argc, char* argv[]) | |
{ | |
double x,y,z,subexp1,subexp2,subexp3,subexp4,subexp5,res; | |
int k; | |
char strx[31] = "",stry[31] = "",strz[31] = ""; | |
printf("Test=1 or Your's variables - any key\n "); | |
scanf("%d", &k); | |
if (k==1) | |
{ | |
x=6.251; y=0.827; z=25.001; | |
subexp1=pow(y,pow(fabs(x),1./3)); | |
subexp2=pow(cos(y),3); | |
subexp3=fabs(x-y); | |
subexp4=1+pow(sin(z),2)/sqrt(x+y); | |
subexp5=exp(abs(x-y))+x/2; | |
res=subexp1+subexp2*subexp3*subexp4/subexp5; | |
printf(" x=%7.4lf \n y=%7.4lf \n z=%7.4lf Rezult= %7.4lf",x,y,z,res); | |
} | |
else | |
{ | |
printf("Type x,y,z\n"); | |
scanf("%s %s %s",&strx,&stry,&strz); | |
if (TryStrToFloat(strx,x) && TryStrToFloat(stry,y) && TryStrToFloat(strz,z) && x!=0) | |
{ | |
subexp1=pow(y,pow(fabs(x),1./3)); | |
subexp2=pow(cos(y),3); | |
subexp3=fabs(x-y); | |
subexp4=1+pow(sin(z),2)/sqrt(x+y); | |
subexp5=exp(abs(x-y))+x/2; | |
res=subexp1+subexp2*subexp3*subexp4/subexp5; | |
printf(" x=%5.5lf \n y=%5.5lf \n z=%5.5lf Rezult= %5.5lf",x,y,z,res); | |
} | |
else | |
{ | |
printf("Error"); | |
} | |
} | |
getch(); | |
return 0; | |
} | |
//--------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment