Check this out!

Nov 27, 2016 at 4:30am
Try running this. Either by pressing gear icon at top right of code box or using your own compiler. I kind of made this by accident.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <cstdlib>
#include <thread>
#include <chrono>

using std::this_thread::sleep_for;
using std::chrono::milliseconds;

int main()
{
    std::srand(time(NULL));
    int d = 1;
    std::cout << "Delay between character prints (ms): ";
    while (!(std::cin >> d) || d < 1)
    {
        std::cin.clear();
        std::cin.ignore(1000000, '\n');
        std::cout << "Invalid. Enter again: ";
    }
    for (int n = 0; n != 50; n++) { std::cout << '\n'; }
    while (true)
    {
        std::cout << static_cast<char> (std::rand() % 300 + 1) << std::flush;
        sleep_for(milliseconds(d));
    }
    
    return 0;
}

There's some issues with my code when running it with the gear icon (http://cpp.sh). Better running it in your own compiler.
Last edited on Nov 27, 2016 at 4:36am
Nov 27, 2016 at 4:46am
What is this program about?
Nov 27, 2016 at 4:49am
Your program is meaningless. Just prints out random characters and that's it.
Nov 27, 2016 at 5:17am
This program should be full of mystery. I made it myself.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <stdio.h>

int main()
{
    int a, b, c;

    for (b = c = 10;
    a = "- FIGURE?, UMKC,XYZHello Folks,\
    TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
    UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
    NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\
    HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\
    T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\
    Hq!WFs XDt!"[b+++21]; )
    for(; a-- > 64 ; )
    putchar (++c=='Z' ? c = c / 9:33^b&1);

    return 0;
}


http://cpp.sh/9rh36
Nov 27, 2016 at 6:19am
Gatenna wrote:
Your program is meaningless. Just prints out random characters and that's it.

Let's keep our manners, now.

My program generates a pseudo-random number 1 through 300 and converts it to char. As you know integars can be converted to char based on the ASCII table.

I would use the <random> library and use random_device but it won't generate truly random numbers on all compilers.

Eg. MinGW GCC.
Last edited on Nov 27, 2016 at 6:25am
Nov 27, 2016 at 6:29am
This program should be full of mystery. I made it myself.

http://stackoverflow.com/questions/3533348/how-does-this-code-generate-the-map-of-india
Nov 27, 2016 at 6:53am
@Gatenna please do not plagerise another person's code. That code which prints the shape of India is old.
Nov 28, 2016 at 4:01am
and interesting too...
Nov 28, 2016 at 7:02am
shadder wrote:
and interesting too...

True. I still haven't figured out completely how it works. Definitely, not how it was created.
Last edited on Nov 28, 2016 at 7:03am
Topic archived. No new replies allowed.