默认计划
9450人加入学习
(205人评价)
《程序设计基础》
价格 免费
音频听课 手机端支持一键听课 (试一试)

{e}^{x}函数exp,log{10}^{x}函数log10

(double x),{x}^{y}函数pow,\sqrt {x}函数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;

}

[展开全文]