در تصویر بالا می خواهم 8 را هم زیر ستون خودش بنویسه این هم کد :
دوست عزیز مشکل شما با استفاده از تابع gotoxy حل میشه.
کد اصلاح شده:
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<iomanip.h>
//begin initialation
const int rowCount=100;
const float h=0.5;
const int infinit=177;
float x=0 ;
int row=1 ;
//end initialation
long double fact(int n){
long double result=1;
int i=1;
for (i=1;i<=n;i++){
result=result*i;
}//for
return result;
}//fact
float y(float x){
return ( exp(x)+(11*exp(-x)) )/2;
}//y
long double adm(float x){
long double result=6+expl(x);
int n=1;
for (n=1;n<=infinit;n++){
result=result+((6*pow(-1,n)* pow(x,n))/fact(n))-(pow(-1,n)*expl(x));
}//for
return result;
}//adm
int main(){
clrscr();
int c=3;
cout<<"#"<<"\t"<<"x"<<"\t"<<"y"<<"\t\t\t\t"<<"adm" <<endl<<endl;
while(row <= rowCount){
cout<<row<<"\t"<<x<<"\t"<<setprecision(10)<<y(x);
gotoxy(49,c);
cout<<adm(x)<<endl;
getch();
row=row+1;
x=x+h;
C++;
}//while
// cout<<adm(750);
getch();
return 0;
}
البته اعداد دو ستون آخر کنترل نشده اند، واسه همین جالب از آب در نمی یاد. اگه اعداد علمی مد نظرتون نیست، می تونید واسه اعداد اعشاریتون میدان تعریف کنید تا یکم خوانا تر شه.