Code:
#include <iostream.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
float Transf(double , double , double *);
FILE * file_open(char name[], char access_mode[]);
int main()
{
FILE *outF;
outF=file_open("output.out","w");
double E, ni, koef[6];
double error;
cout<<" E: ";
cin>>E;
cout<<"\n ni: ";
cin>>ni;
Transf(E, ni, &koef);
if(!error)
{
fprintf(outF," -> input-output <-\n");
fprintf(outF," Young's Modulus : %8.3e\n",E);
fprintf(outF," Poasson Ratio : %8.3e\n",ni);
for(int i=0;i<6;i++)
{
fprintf(outF," D[",i,"] : %8.3e\n",koef[i]);
}
}
else
fprintf(outF," Greska!!!\n ni mora biti manje od 0.5!!!");
return 0;
}
float Transf(double Elast, double Poiss, double *pKoef[6])
{
short Value=0;
if(Poiss>0.5)
Value=1;
else
{
for(int i=0;i<3;i++)
{
*pKoef[i]=Elast*(1-Poiss)/((1+Poiss)*(1-2*Poiss));
}
for(int j=3;j<6;j++)
{
*pKoef[j]=Elast*Poiss/((1+Poiss)*(1-2*Poiss));
}
}
return Value;
}
FILE *file_open(char name[], char access_mode[])
{
FILE *f;
f=fopen(name, access_mode);
if(f==NULL)
{
perror("Ne mogu da otvorim fajl!!!");
exit(1);
}
return f;
}
#include <iostream.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
float Transf(double , double , double *);
FILE * file_open(char name[], char access_mode[]);
int main()
{
FILE *outF;
outF=file_open("output.out","w");
double E, ni, koef[6];
double error;
cout<<" E: ";
cin>>E;
cout<<"\n ni: ";
cin>>ni;
Transf(E, ni, &koef);
if(!error)
{
fprintf(outF," -> input-output <-\n");
fprintf(outF," Young's Modulus : %8.3e\n",E);
fprintf(outF," Poasson Ratio : %8.3e\n",ni);
for(int i=0;i<6;i++)
{
fprintf(outF," D[",i,"] : %8.3e\n",koef[i]);
}
}
else
fprintf(outF," Greska!!!\n ni mora biti manje od 0.5!!!");
return 0;
}
float Transf(double Elast, double Poiss, double *pKoef[6])
{
short Value=0;
if(Poiss>0.5)
Value=1;
else
{
for(int i=0;i<3;i++)
{
*pKoef[i]=Elast*(1-Poiss)/((1+Poiss)*(1-2*Poiss));
}
for(int j=3;j<6;j++)
{
*pKoef[j]=Elast*Poiss/((1+Poiss)*(1-2*Poiss));
}
}
return Value;
}
FILE *file_open(char name[], char access_mode[])
{
FILE *f;
f=fopen(name, access_mode);
if(f==NULL)
{
perror("Ne mogu da otvorim fajl!!!");
exit(1);
}
return f;
}
1+1=2