今天发现一个简单的输出字符串方法,解决C和C++中prinft和cout不能多行输出的问题。
首先是cout
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
cout<< " ********\n"
"************\n"
"####....#.\n"
"#..###.....##....\n"
"###.......###### ### ###\n";
}
还可以直接加一个R"()";
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
cout<< R"( ********
************
####....#.
#..###.....##....
###.......###### ### ###)";
}
然后是printf,它和cout差不多
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
printf(R"( ********
************
####....#.
#..###.....##....
###.......###### ### ###)");
}
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
printf( " ********\n"
"************\n"
"####....#.\n"
"#..###.....##....\n"
"###.......###### ### ###\n");
}
欧克,今天的笔记就到这里啦。