C++ 中的 ASCII 艺术

ASCII art in C++

我试图在 C++ 程序中输入 ASCII art 并通过手动打印每一行来完成,但结果与 ASCII 艺术完全不同。就像:

出现这种情况是因为提示无法识别字符还是我操作不正确?

这是我正在尝试做的 ASCII 艺术:

_____/\\\\\________/\\\\\\__________/\\\\\__/\\\\\\__/\\\\\\_        
 ___/\\\\\\\____/\\/////////\\_____/\\////////__\/////\\///__\/////\\///__       
  __/\\/////////\\__\//\\______\///____/\\/_______________\/\\_________\/\\_____      
   _\/\\_______\/\\___\////\\__________/\\_________________\/\\_________\/\\_____     
    _\/\\\\\\\\______\////\\______\/\\_________________\/\\_________\/\\_____    
     _\/\\/////////\\_________\////\\___\//\\________________\/\\_________\/\\_____   
      _\/\\_______\/\\__/\\______\//\\___\///\\______________\/\\_________\/\\_____  
       _\/\\_______\/\\_\///\\\\\\/______\////\\\\\__/\\\\\\__/\\\\\\_ 
        _\///________\///____\///////////___________\/////////__\///////////__\///////////__

代码:

cout << "_____/\\\\\________/\\\\\\__________/\\\\\__/\\\\\\__/\\\\\\_        \n";
cout << " ___/\\\\\\\____/\\/////////\\_____/\\////////__\/////\\///__\/////\\///__       \n";
cout << "  __/\\/////////\\__\//\\______\///____/\\/_______________\/\\_________\/\\_____      \n";
cout << "  _\/\\_______\/\\___\////\\__________/\\_________________\/\\_________\/\\_____     \n";
cout << "    _\/\\\\\\\\______\////\\______\/\\_________________\/\\_________\/\\_____    \n";
cout << "    _\/\\/////////\\_________\////\\___\//\\________________\/\\_________\/\\_____   \n";
cout << "      _\/\\_______\/\\__/\\______\//\\___\///\\______________\/\\_________\/\\_____  \n";
cout << "       _\///________\///____\///////////___________\/////////__\///////////__\///////////__\n";

escape sequences 被解释为单个特殊字符或其他字符,因此出现奇怪的输出。例如,"\" 表示 '\'

您可以使用原始字符串文字:

#include <iostream>

int main()
{
    std::cout << R"(
_____/\\\\\________/\\\\\\__________/\\\\\__/\\\\\\__/\\\\\\_        
 ___/\\\\\\\____/\\/////////\\_____/\\////////__\/////\\///__\/////\\///__       
  __/\\/////////\\__\//\\______\///____/\\/_______________\/\\_________\/\\_____      
   _\/\\_______\/\\___\////\\__________/\\_________________\/\\_________\/\\_____     
    _\/\\\\\\\\______\////\\______\/\\_________________\/\\_________\/\\_____    
     _\/\\/////////\\_________\////\\___\//\\________________\/\\_________\/\\_____   
      _\/\\_______\/\\__/\\______\//\\___\///\\______________\/\\_________\/\\_____  
       _\/\\_______\/\\_\///\\\\\\/______\////\\\\\__/\\\\\\__/\\\\\\_ 
        _\///________\///____\///////////___________\/////////__\///////////__\///////////__        
)" << '\n';

    return 0;
}

live demo