/* time:2020年4月20日21:29:20 where:gfdx function:函数使用*/ #include<iostream> using namespace std; //加法 double addiction(double num1, double num2); double addiction(double num1, double num2) { return num1 +num2; } //减法 double subtraction(double num1, double num2); double subtraction(double num1, double num2) { return num1 - num2; } //乘法 double multiplication(double num1, double num2); double multiplication(double num1, double num2) { return num1 * num2; } //除法 double division(double num1, double num2); double division(double num1, double num2) { if (num2 != 0) { return num1 / num2; } else { cout << "除数不能为0" << endl; } } int main() { int a, b;//输入的值 int i;//记录循环次数 int j = 10;//记录输入的次数 cout <<‘\t‘<< "******欢迎使用简单四则运算程序1.0******" << endl; for (i = 0; i <= 10; i++) { cout << "请输入两个数,用空格隔开,以便于计算!" << endl; cin >> a >> b; cout << "加法:" << addiction(a, b) << endl;//调用加法函数 cout << "减法" << subtraction(a, b) << endl;//调用减法函数 cout << "乘法:" << multiplication(a, b) << endl;//调用乘法函数 cout << "除法:" << division(a, b) << endl;//调用除法函数 cout <<"你还有"<<j--<<"次机会!"<< endl; } return 0; }
原文:https://www.cnblogs.com/qq1480040000/p/12740825.html