尝试编写使用数组计算标准偏差的程序。 它一直给我一个错误:
" LNK2019未解析的外部符号_main在函数" int中引用 __cdecl invoke_main(void)" (?invoke_main @@ YAHXZ)ConsoleApplication7777 C:\ Users \ Gregory \ Desktop \ ConsoleApplication7777 \ ConsoleApplication7777 \ MSVCRTD.lib(exe_main.obj)1"
这是我的代码:
#include "stdafx.h"
#include<iostream>
#include<cmath>
using namespace std;
double standard_Deviation(double x[], int n);
//Main Function here
void Main()
{
//declare variables here
double x[100];
double sDeviation;
int i;
int n;
//input number values here
cout << "Enter n value";
cin >> n;
//input array values here
cout << "Enter values:" << endl;
for (i = 0; i < n; i++)
cin >> x[i];
//call standard deviation function
sDeviation = standard_Deviation(x, n);
//outputting standard deviation
cout << "Standard Deviation:" << sDeviation << endl;
//give it time to think
system("pause");
}
double standard_Deviation(double x[], int n)
{
double sd = 0;
double mean=0;
for (int i = 0; i<n; i++)
mean = mean + x[i];
mean = mean / n;
for (int i = 0; i<n; i++)
sd = sd + pow((x[i] - mean), 2);
sd = sd / n;
sd = sqrt(sd);
return sd;
return mean;
} //end of standard deviation
答案 0 :(得分:1)
参加C和C ++的区分大小写;链接器寻找的主程序是
int main() {/**/}
不
void Main(){/* ... */}
答案 1 :(得分:0)
替换
void Main()
带
int main()
应用程序需要main
函数(具有int
返回类型)并且这是链接器抱怨的内容,因为您没有提供一个由于您的大写字母错误{{1} }。