函数exp,函数log10
(double x),函数pow,函数sqrt
加注释;掌握算数运算符和常用函数;程序的结构
函数exp,函数log10
(double x),函数pow,函数sqrt
加注释;掌握算数运算符和常用函数;程序的结构
以符号#开头的行,称为编译预处理行
#include称为文件预处理命令
#include <iostream> //预编译命令
using namespace std
int main() //主函数
{
float ApplePrice=3.5; //苹果单价,3.5元/千克//
float bananaPriace=4.2; //香蕉单价,4.2元/千克//
float PeanutPrice=5.0; //花生单价,5.0/千克
float AppleWeight=0; //苹果重量,初始化为0//
float bananaWeight=0 ; //香蕉重量,初始化为0//
float PeanutWeight=0; //花生重要,初始化为0//
float total; //总钱数
cout<<"请输入要采购的苹果重量"<<endl; //提示信息//
cin>>AppleWeight;
cout<<"请输入要采购的香蕉重量"<<endl;
cin>>bananaWeight;
cout<<"请输入要采购的花生重量"<<endl;
cin>>PeanutWeight;
total=ApplePrice*AppleWeight+bananaPrice*bananaWeight+PeanutPrice*PeanutWeight;
cout<<"总金额"<<total<<endl;
return 0;
}