C++编程项目请教
发布网友
发布时间:2022-09-15 01:14
我来回答
共2个回答
热心网友
时间:2024-12-02 17:48
如果人的体重和老鼠的体重与剂量的关系成正比
# include <iostream>
# include <iomanip>
# include <cstdlib>
using namespace std;
double n;//用于存放剂量的变量
const double p=0.001;//必要时可以通过输入来替换
double Func(double a,double mw,double pw)
{
return pw/mw*a*p;
}
int main(int argc,char* argv[])
{
double a,mw,pw;
double r;
char c[5]="true";//初始化
while (strcmp(c,"exit"))
{
cout<<"Input the weight of the mouse:\n"
<<"and the weight of the people:"<<endl;
cin>>mw>>pw;
cout<<"Input the usage of the drink:"<<endl;
cin>>a;
r=Func(a,mw,pw);
cout<<"You have to drink less than "<<r<<endl;
cin>>c;
}
return 0;
}
热心网友
时间:2024-12-02 17:48
别用double 用 unsigned long 然后设定一个较小的基值“1”