看了两章不到。。随意记录下。

#include<iostream>
#include<string>
using std::cout;
using std::endl;
double calculation(double a,double b,char op)
{
	switch(op)
	{
		case '+': return a+b;
		case '-':return a-b;
		case '*':return a*b;
		case '/':return a/b;
	}
	

	
}
 double num=0;
 double num2=0;
 char op='a';
int main()
{
	//
	//int num=2;
	//cout<<test();
	//std::cin>>::num;
	//cout<<num;
	//std::string wenzi="hhaha";
	//cout<<wenzi;
	cout<<"不科学计算器\n请输入两个数字\n请输入第一个数\n";
	std::cin>>::num;
	cout<<"请输入第二个数\n";
	std::cin>>::num2;
	cout<<"请输入运算符 +,-,*,/\n";
	std::cin>>op;
	cout<<"您的结果为:\n";
	cout<<calculation(num,num2,op);

	return 0;//退出这个程序
}

  其实最主要的是在群里学到了一个有意思的东西 就是 

include<string> 原来在c++里面不能直接使用string类型,后来想通,string是引用类型。。

相关文章:

  • 2021-11-26
  • 2022-12-23
  • 2022-02-25
  • 2021-07-06
  • 2021-10-03
  • 2021-09-03
  • 2022-01-22
  • 2021-07-16
猜你喜欢
  • 2022-01-06
  • 2021-07-01
  • 2022-01-12
  • 2022-12-23
  • 2021-04-10
相关资源
相似解决方案