有人可以帮助解释为什么当我乘以2个数字时它会返回0,但它有3个和4个数字吗?
我为一堂课写了这篇文章,但我不知道它有什么不对,谢谢.
功能是使用重载函数乘以2,3或4个数字,并通过引用传递产品.
#include <iostream>
using namespace std;
void mult(int& product, int n1, int n2);
void mult(int& product, int n1, int n2, int n3);
void mult(int& product, int n1, int n2, int n3, int n4);
int main() {
int product, n1, n2, n3, n4;
char ans;
do {
product = 0;
n1 = 0;
n2 = 0;
n3 = 0;
n4 = 0;
cout << "Enter 2-4 numbers to multiply\n";
cout << "First number: ";
cin >> n1;
cout << …Run Code Online (Sandbox Code Playgroud) 我需要计算读取的15个数字的方差和标准差.我不知道为什么但功能不会执行,控制台只是闪烁.有人可以解释一下问题是什么,谢谢.
#include <iostream>
using namespace std;
void stats(int array[], double& var, double& sd);
int main ()
{
int array[15];
double var = 0, sd = 0;
cout << "Please enter 15 numbers to calculate var and SD\n";
for(int i = 0; i < 15; i++)
{
cout << "Enter number: ";
cin >> array[i];
}
stats(array,var,sd);
cout << "Numbers entered are: ";
for(int i = 0; i < 15; i++)
{
cout << array[i] << " ";
}
cout << …Run Code Online (Sandbox Code Playgroud)