[Article 1] Simple ascii art generator, asciiart
Hello, everyone. Welcome to visit.
I am Shui Ming and applied for this blog in the early morning of June January 13, 2016.
A newbie cannot speak loudly. Please wait for a while ~
Recently, I read "c ++ primer plus", which contains a sentence "Houdini used to draw a Hudson River Chart Only when only escape sequences were used; he is undoubtedly a master of escape sequence art." I wrote a simple ASCII ART generator.
This is a funny look:
This is the emblem of the College where the blogger is located:
Implementation process:
Output graphics
--@@
---@@@
@@
It can be seen that two "-" and two "@" are output, and a line feed is output. Three "-" and three "@" are output.
Input data is
2 2 0 0
3 3 0 0
0 2 0 0
(Reading data is like playing a "number Chart" game. Data is collected in ps .)
Defines a function of the string type. The parameter is the number of characters c1 n1 and the number of characters c2 n2. the return value is string (n1, c1) + string (n2, c2 ).
When n2 is 0, the line feed is output.
Code:
# Include <iostream>
# Include <string>
# Include <fstream>
Using namespace std;
Const char c1 = '';
Const char c2 = '@';
Int main ()
{
Ifstream cin ("data.txt ");
String str (int, int );
Int n1, n2;
While (cin> n1> n2)
{
If (n2 = 0)
Cout <endl;
Else
Cout <str (n1, n2 );
}
Return 0;
}
String str (int n1, int n2)
{
Return string (n1, c1) + string (n2, c2 );
}
Txt file of the "funny" image:
26 8 0 0
19 6 10 6 0 0
11 9 22 6 0 0
12 2 3 5 17 4 3 2 0 0
10 2 7 3 17 3 6 2 0
8 2 40 2 0 0
6 17 13 17 0 0
5 7 12 1 10 7 12 1 0 0
5 15 5 1 9 15 5 1 0 0
4 2 2 3 10 4 13 3 10 5 0 0
3 2 50 2 0 0
3 1 52 1 0 0
3 1 52 1 0 0
2 2 52 2 0 0
2 2 52 2 0 0
2 2 52 2 0 0
2 2 52 2 0 0
3 1 5 1 40 1 5 1 0 0
3 2 5 1 38 1 5 2 0 0
4 1 6 2 34 2 6 1 0 0
5 1 7 3 28 3 7 1 0 0
6 1 8 4 22 4 8 1 0 0
7 2 10 5 12 5 10 2 0 0
9 2 12 14 12 2 0 0
11 3 32 3 0 0
14 3 26 3 0 0
17 5 16 5 0 0
22 16 0 0
Txt file of the Emblem:
29 4 0 0
26 9 0 0
24 13 0 0
21 18 0 0
19 22 0 0
17 26 0 0
14 31 0 0
12 13 16 6 0 0
10 11 23 5 0 0
9 10 9 10 8 5 0 0
9 9 5 19 7 4 0 0
10 8 3 6 10 8 7 3 0 0
12 7 2 3 2 8 6 7 2 0 0
2 1 11 7 2 4 3 6 5 8 7 1 0 0
3 2 11 19 5 10 0 0
5 3 14 10 7 12 0 0
7 4 26 15 0 0
10 5 20 17 0 0
12 10 7 21 0 0
14 34 0 0
16 30 0 0
18 26 0 0
20 22 0 0
22 18 0 0
24 14 0 0
26 10 0 0
28 6 0 0
(If you have time, write a data record for the quickplay logo ......)
Think: Can I open an image and generate ASCII ART automatically. The current level is not up yet.