如何在c++运行时输入一次数据以后不会出现press any key to continue还可以继续输入数据 5
#include<iostream>usingnamespacestd;doublezy(doublex,doublea1,doublea2,doublea3,doubl...
#include<iostream>
using namespace std;
double zy(double x,double a1,double a2,double a3,double a4,double a5)
{double y;
y=(a1+(a2+(a3+(a4+a5* x)*x)*x)*x);//四项式表达式
return y;
}
double zy(double x ,double a1 ,double=0 ,double=0 ,double=0 ,double=0 );
void main()
{double x;
cout<<"请输入x:";
cin>>x;
cout<<"zy(x,9)="<<zy(x,1)<<endl;
cout<<"zy(x,9,8)="<<zy(x,1,2)<<endl;
cout<<"zy(x,9,8,7)="<<zy(x,1,2,3)<<endl;
cout<<"zy(x,9,8,7,6)="<<zy(x,1,2,3,4)<<endl;
cout<<"zy(x,9,8,7,6,5)="<<zy(x,1,2,3,4,5)<<endl;
} 展开
using namespace std;
double zy(double x,double a1,double a2,double a3,double a4,double a5)
{double y;
y=(a1+(a2+(a3+(a4+a5* x)*x)*x)*x);//四项式表达式
return y;
}
double zy(double x ,double a1 ,double=0 ,double=0 ,double=0 ,double=0 );
void main()
{double x;
cout<<"请输入x:";
cin>>x;
cout<<"zy(x,9)="<<zy(x,1)<<endl;
cout<<"zy(x,9,8)="<<zy(x,1,2)<<endl;
cout<<"zy(x,9,8,7)="<<zy(x,1,2,3)<<endl;
cout<<"zy(x,9,8,7,6)="<<zy(x,1,2,3,4)<<endl;
cout<<"zy(x,9,8,7,6,5)="<<zy(x,1,2,3,4,5)<<endl;
} 展开
2个回答
展开全部
while(true)
{
cout<<"请输入x:";
cin>>x;
cout<<"zy(x,9)="<<zy(x,1)<<endl;
cout<<"zy(x,9,8)="<<zy(x,1,2)<<endl;
cout<<"zy(x,9,8,7)="<<zy(x,1,2,3)<<endl;
cout<<"zy(x,9,8,7,6)="<<zy(x,1,2,3,4)<<endl;
cout<<"zy(x,9,8,7,6,5)="<<zy(x,1,2,3,4,5)<<endl;
}
{
cout<<"请输入x:";
cin>>x;
cout<<"zy(x,9)="<<zy(x,1)<<endl;
cout<<"zy(x,9,8)="<<zy(x,1,2)<<endl;
cout<<"zy(x,9,8,7)="<<zy(x,1,2,3)<<endl;
cout<<"zy(x,9,8,7,6)="<<zy(x,1,2,3,4)<<endl;
cout<<"zy(x,9,8,7,6,5)="<<zy(x,1,2,3,4,5)<<endl;
}
追问
这不是死循环么。。。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
使用循环即可。
追问
怎么加,你加上去试试 我不会加 加上去就进入死循环不出数据
追答
加了循环后加一个判断,设置在某种条件下可以跳出循环。比如说这样:
#include<iostream>
using namespace std;
double zy(double x,double a1,double a2,double a3,double a4,double a5)
{
double y;
y=(a1+(a2+(a3+(a4+a5* x)*x)*x)*x);//四项式表达式
return y;
}
double zy(double x ,double a1 ,double=0 ,double=0 ,double=0 ,double=0 );
int main()
{
double x;
while (true)
{
cout<<"请输入x:";
cin>>x;
if (x==0)
{
break;
}
cout<<"zy(x,9)="<<zy(x,1)<<endl;
cout<<"zy(x,9,8)="<<zy(x,1,2)<<endl;
cout<<"zy(x,9,8,7)="<<zy(x,1,2,3)<<endl;
cout<<"zy(x,9,8,7,6)="<<zy(x,1,2,3,4)<<endl;
cout<<"zy(x,9,8,7,6,5)="<<zy(x,1,2,3,4,5)<<endl;
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询