[C++] Summary of C++ Special Usage (2) Super Format Output

Sometimes, we always encounter such boring things

Please use the C\C++ program to output the following graphics (no space after it)
Disgusting picture

Then since it is a certain image, we can solve it with a bunch of printf/cout (I think someone who writes in a printf/cout should not have it)

But can we output like python?
(Python can use the format of ``'''' to solve multi-line strings)
C++'s "R" expression can solve this serious problem, just go to the code

    printf(R"(
     *
    ***
   *****
  *******
 *********
***********
 *********
  *******
   *****
    ***
     *)");

Of course cout is also possible

    cout<<R"(
     *
    ***
   *****
  *******
 *********
***********
 *********
  *******
   *****
    ***
     *)";

The format is

R "(here is the text to be output)"

When outputting, the parentheses will not be output. What if we want to output the parentheses?
A format is also provided here

cout<<R"+*("(This text will contain brackets)")+*"<<endl;

The output result is

(This text will contain brackets)

Guess you like

Origin blog.csdn.net/m0_43448982/article/details/89340794