我有一个基本问题,希望有人可以帮助我。我非常有信心这是一个小型,健忘的问题,缺少回报或类似的东西。
///////////////////////////
//My Basic Calculator App
//Written by l8nit3tr0ubl3
//of NottaDev inc.
///////////////////////////
#include <iostream>
void in() //Take input from user, all 3 variables.
{
int add(int, int); //Forward declarations
int minus(int, int);
int divide(int, int);
int multiply(int, int);//end declarations
std::cout << "My Basic Calculator\n";//take inputs
std::cout << "Please input your first number.\n";
int firstNumber;
std::cin >> firstNumber;
std::cout << "Choose math function.\n";
std::cout << "Eg. *-+/\n";
char operatorType;
std::cin >> operatorType;
std::cout << "Please input second number.\n";
int secondNumber;
std::cin >> secondNumber;//end inputs
if (operatorType == '+') //determine math function to use
add(firstNumber, secondNumber);
else if (operatorType == '-')
minus(firstNumber, secondNumber);
else if (operatorType == '/')
divide(firstNumber, secondNumber);
else if (operatorType == '*')
multiply(firstNumber, secondNumber);//end math function
}
int add(int firstNumber, int secondNumber) //Actual math is done
{
return firstNumber + secondNumber;
}
int minus(int firstNumber, int secondNumber)
{
return firstNumber - secondNumber;
}
int divide(int firstNumber, int secondNumber)
{
return firstNumber / secondNumber;
}
int multiply(int firstNumber, int secondNumber)
{
return firstNumber * secondNumber; //End math
}
int main()
{
in(); //Call input, which will call math function
return 0; //return '0' for no error.
}
有人可以告诉我忘记打电话或退回吗?
我应该对我的问题更加准确,并且我为没有这样做而道歉。没有产生错误,我根本无法回应我对控制台的回答。但是,下面提供了一个完美的答案
答案 0 :(得分:3)
您的add
,multiply
等函数会返回操作结果,但您没有对其执行任何操作。
你可以打印它:
std::cout << add(firstNumber, secondNumber) << std::endl;
答案 1 :(得分:2)
您可能希望输出计算结果。 所以写
result = add(firstNumber, secondNumber);
但更好的是,如果你只输出一次。为此使用一个temprary变量,例如
std::cout << "The result is " << result << std:endl;
...
import time, resource, os
import boto
conn = boto.connect_s3()
for i in range(20):
print resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
path = 'test.png'
bucket = conn.lookup('jca-screenshots-' + ('thumbs' if i % 2 == 0 else 'normal'))
k = boto.s3.key.Key(bucket)
k.key = os.path.basename(path)
k.set_contents_from_filename(path)
time.sleep(5)
答案 2 :(得分:0)
你的add,multiply和minus函数在()中返回void,并且在返回它们时没有为它们分配变量。