มีคำสั่งจากโปรเเกรมVisual studio 2010 มา
อยากทราบว่า ถ้าต้องการเเปลงคำสั่งเพื่อใช้กับโปรเเกรม code block ต้องแปลงยังไง??คะ
คำสั่งประมาณนี้คะ--------------------------------------------------------------------------------
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <conio.h>
int _tmain(int argc, _TCHAR* argv[])
{
float c[3],cc[10][3],mu[3],fc[3],m[3],kd[3],Ys[3],Yp[3],a[3],cin[3];
float Xc[100][3],Xt[100];
float t,nint,h,tmax,phyP,phyS,phyD,kp,ksi,mum,ks,fout,fin,pi;
int i,j,k,n;
char ch;
printf("\n\n\n\n\n\t\t\tBatch Fermentation simulation program\n");
printf("\t\t***********************************************");
printf("\n\n\n");
printf("\t\t\t\tEnter to continue");
scanf_s("%c",&ch);
system("cls");
printf("Enter only values of constants to be used\n");
printf("Enter 0 for canstant not applicable\n\n");
printf("initial biomass concentration(c(0)) =");
scanf_s("%f",&c[0]);
cin[0]=c[0];
printf("initial substrate concentration(c(1)) =");
scanf_s("%f",&c[1]);
cin[1]=c[1];
printf("initial substrate concentration(c(2)) = 0\n");
c[2]=0;
cin[2] = c[2];
printf("maximum specific growth rate(mum)=");
scanf_s("%f",&mum);
printf("saturation growth constant(ks)=");
scanf_s("%f",&ks);
printf("product inhibition(kp)=");
scanf_s("%f",&kp);
printf("substrate inhibition(ksi)=");
scanf_s("%f",&ksi);
printf("maintenance coefficient(m)=");
scanf_s("%f",&m[1]);
m[2]=m[1];
m[0]=0;
printf("specific cell death rate(kd)=");
scanf_s("%f",&kd[0]);
kd[2]=-kd[0];
kd[1]=0;
printf("yield coefficient for biomass on substrate(Yx)=");
scanf_s("%f",&Ys[1]);
Ys[0]=1;
Ys[2]=1;
printf("yield coefficient for product on substrate(Yp)=");
scanf_s("%f",&Yp[2]);
Yp[0]=1;
Yp[1]=1;;
printf("flow rate in(fin)=");
scanf_s("%f",&fin);
printf("flow rate out(fout)=");
scanf_s("%f",&fout);
printf("total fermentation time(tmax)=");
scanf_s("%f",&tmax);
printf("percent of product inhibition(pi)=");
scanf_s("%f",&pi);
a[0]=1;
a[1]=-1;
a[2]=1;
system("cls");
nint=tmax/10;
h=nint/10;
k=0;
n=0;
t=0;
for(int x=0;x<10;x++){
t+=nint;
for(j=0;j<10;j++){
phyP = 1/(1+(c[2]/kp));
if(ksi==0){
phyS = 1;
}else{
phyS = ksi/(ksi+c[1]);
}
phyD = 1;
for(i=0;i<3;i++){
mu
=((((mum*c[1]*phyP*phyD*phyS)/(ks+c[1]))-kd)*(Yp/Ys)+m)*a;
fc=(mu*c[0])+(fin*cin)-(fout*c);
c=c+(h*fc);
cc[k]=c;//keep history of concentration for only big step
Xc[n]=c;//keep history of concentration for all step
}
Xt[n]=t;//keep history of time
n = n+1;
}
printf("flow rate in(fin)=%f\n",fin);
printf("k=%d\n",k+1);
printf("t=%.2f\n",t);
printf("biomass concentration(c(0))=%.2f\nsubstrate concentration(c(1))=%.2f\nproduct concentration(c(2))=%.2f\n\n",cc[k][0],cc[k][1],cc[k][2]);
k=k+1;
}
printf("n\tk\tt\tc(0)\tc(1)\tc(2)\n");
n=0;
for(i=0;i<k;i++)
{
for(j=0;j<10;j++)
{
printf("%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",n+1,i+1,Xt[n],Xc[n][0],Xc[n][1],Xc[n][2]);
n++;
}
}
printf("\n\n enter to exit");
scanf_s("%d",&n);
return 0;
}
สอบถามการแปลงคำสั่งจากโปรแกรม Visual studio 2010 ไปใช้กับโปรเเกรม code block
อยากทราบว่า ถ้าต้องการเเปลงคำสั่งเพื่อใช้กับโปรเเกรม code block ต้องแปลงยังไง??คะ
คำสั่งประมาณนี้คะ--------------------------------------------------------------------------------
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <conio.h>
int _tmain(int argc, _TCHAR* argv[])
{
float c[3],cc[10][3],mu[3],fc[3],m[3],kd[3],Ys[3],Yp[3],a[3],cin[3];
float Xc[100][3],Xt[100];
float t,nint,h,tmax,phyP,phyS,phyD,kp,ksi,mum,ks,fout,fin,pi;
int i,j,k,n;
char ch;
printf("\n\n\n\n\n\t\t\tBatch Fermentation simulation program\n");
printf("\t\t***********************************************");
printf("\n\n\n");
printf("\t\t\t\tEnter to continue");
scanf_s("%c",&ch);
system("cls");
printf("Enter only values of constants to be used\n");
printf("Enter 0 for canstant not applicable\n\n");
printf("initial biomass concentration(c(0)) =");
scanf_s("%f",&c[0]);
cin[0]=c[0];
printf("initial substrate concentration(c(1)) =");
scanf_s("%f",&c[1]);
cin[1]=c[1];
printf("initial substrate concentration(c(2)) = 0\n");
c[2]=0;
cin[2] = c[2];
printf("maximum specific growth rate(mum)=");
scanf_s("%f",&mum);
printf("saturation growth constant(ks)=");
scanf_s("%f",&ks);
printf("product inhibition(kp)=");
scanf_s("%f",&kp);
printf("substrate inhibition(ksi)=");
scanf_s("%f",&ksi);
printf("maintenance coefficient(m)=");
scanf_s("%f",&m[1]);
m[2]=m[1];
m[0]=0;
printf("specific cell death rate(kd)=");
scanf_s("%f",&kd[0]);
kd[2]=-kd[0];
kd[1]=0;
printf("yield coefficient for biomass on substrate(Yx)=");
scanf_s("%f",&Ys[1]);
Ys[0]=1;
Ys[2]=1;
printf("yield coefficient for product on substrate(Yp)=");
scanf_s("%f",&Yp[2]);
Yp[0]=1;
Yp[1]=1;;
printf("flow rate in(fin)=");
scanf_s("%f",&fin);
printf("flow rate out(fout)=");
scanf_s("%f",&fout);
printf("total fermentation time(tmax)=");
scanf_s("%f",&tmax);
printf("percent of product inhibition(pi)=");
scanf_s("%f",&pi);
a[0]=1;
a[1]=-1;
a[2]=1;
system("cls");
nint=tmax/10;
h=nint/10;
k=0;
n=0;
t=0;
for(int x=0;x<10;x++){
t+=nint;
for(j=0;j<10;j++){
phyP = 1/(1+(c[2]/kp));
if(ksi==0){
phyS = 1;
}else{
phyS = ksi/(ksi+c[1]);
}
phyD = 1;
for(i=0;i<3;i++){
mu=((((mum*c[1]*phyP*phyD*phyS)/(ks+c[1]))-kd)*(Yp/Ys)+m)*a;
fc=(mu*c[0])+(fin*cin)-(fout*c);
c=c+(h*fc);
cc[k]=c;//keep history of concentration for only big step
Xc[n]=c;//keep history of concentration for all step
}
Xt[n]=t;//keep history of time
n = n+1;
}
printf("flow rate in(fin)=%f\n",fin);
printf("k=%d\n",k+1);
printf("t=%.2f\n",t);
printf("biomass concentration(c(0))=%.2f\nsubstrate concentration(c(1))=%.2f\nproduct concentration(c(2))=%.2f\n\n",cc[k][0],cc[k][1],cc[k][2]);
k=k+1;
}
printf("n\tk\tt\tc(0)\tc(1)\tc(2)\n");
n=0;
for(i=0;i<k;i++)
{
for(j=0;j<10;j++)
{
printf("%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",n+1,i+1,Xt[n],Xc[n][0],Xc[n][1],Xc[n][2]);
n++;
}
}
printf("\n\n enter to exit");
scanf_s("%d",&n);
return 0;
}