简单程序"LNK1561 entry point must be defined"



这是我的代码:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int x;
    int y = pow(2, x);
    cin>>x;
    cout<< y;
    system("pause");
    return 0;
}

为什么我会出现编译错误?LNK1561 entry point must be defined

我正在使用Visual Studio学习版。

在使用之前,您需要为x分配一个值

int x;
int y = pow(2, x); // <--- what is the value of x here?

首先尝试从输入中获取x的值。

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int x;
    cin >> x;
    int y = pow(2, x);
    cout<< y; 
    system("pause");
    return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int x;
    //int y = pow(2, x);//(1)
    //cin>>x;//(2)
    //exchange the lines (2) and (1)
    cin>>x;//(2)
    int y = pow(2, x);//(1)
    cout<< y; 
    system("pause");
    return 0;
}

相关内容

最新更新