c++ - 如何在开发 C++ 中输出 pi 符号

标签 c++ dev-c++

#include <cstdlib>
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
cout << "pi symbol";
getch();
return EXIT_SUCCESS;
}

我必须在 dev C++ 中输出一个圆周率符号。 很多天以来我一直在寻找它,请帮助我。

最佳答案

要使用 devcpp 显示 pi,您需要它的 unicode(正如 p-a-o-l-o 在评论\u03C0 中所写)。更重要的是你应该使用 wide characters并设置标准输出模式。 这是工作解决方案:

#include <iostream>
#include <io.h>
#include <wchar.h>

using namespace std;

int main(void)
{
    _setmode(_fileno(stdout), 0x10000);
    wchar_t *pi = L"\u03C0";
    wcout<<pi;
    cout<<endl;

    return 0;
}

关于c++ - 如何在开发 C++ 中输出 pi 符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49752219/

相关文章:

c# - C++ C# 委托(delegate)等效

映射中的 C++ 结构作为值 - 错误 "no instance of overloaded function matches the argument list"

c++ log函数使用浮点精度

c++ - 在 C++ 中使用模板时,编译器如何知道要实例化多少数据类型?

c++ - 使用他们的包在 Dev-C++ 中安装 Allegro

c - 为什么此代码在 Dev-C++ 中有效,但在 Visual C++ 中无效?

c++ - 为什么 boost::fusion::as_set 不从 boost::fusion::vector 中删除重复项?

c++ - 尝试链接 libcurl 时遇到问题

c - 为什么改变变量定义的顺序会改变代码的功能

windows - 在 Dev-C++ 中编译 Windows 程序会出错