A c++ Program for Valentines day

Discussion in 'C++' started by sandy, Feb 6, 2006.

  1. sandy

    sandy Guest

    Hey guys,

    I know this is silly, but I just wanted to take some break from work. I
    was just wodering if its possible to write a c++ program that can print
    "iloveyou" in shape of 'heart' when executed. The impotant thing is
    that, the program should not show any kind of words related to it, i
    mean the program should not be understandable at the very first sight
    the user goes through the code. It will be gr8 if something more
    creative is achieved out of this idea. Think about it. Let me know if
    its possible to make a code that can interact with user and print the
    results for just one particular kind of input, and print it in a
    beautiful way. I am not good enough in c++ to do that, so i was just
    wondering someone can help me out with it. Thank you.

    sandy
    sandy, Feb 6, 2006
    #1
    1. Advertising

  2. sandy

    Mike Wahler Guest

    "sandy" <> wrote in message
    news:...
    > Hey guys,
    >
    > I know this is silly, but I just wanted to take some break from work. I
    > was just wodering if its possible to write a c++ program that can print
    > "iloveyou" in shape of 'heart' when executed.


    Certainly.

    > The impotant thing is


    Don't say that on Valentine's Day. :)

    > that, the program should not show any kind of words related to it, i
    > mean the program should not be understandable at the very first sight
    > the user goes through the code. It will be gr8 if something more
    > creative is achieved out of this idea. Think about it. Let me know if
    > its possible to make a code that can interact with user and print the
    > results for just one particular kind of input, and print it in a
    > beautiful way. I am not good enough in c++ to do that, so i was just
    > wondering someone can help me out with it. Thank you.


    Get some graph paper, and draw the characters (perhaps asterisks) of
    the output. After that it should be simple to write some loops to
    output various character sequences. If you want to further obfuscate
    the source, put random amounts of it in separate functions.

    -Mike
    Mike Wahler, Feb 7, 2006
    #2
    1. Advertising

  3. sandy

    Daniel T. Guest

    In article <mDSFf.10811$>,
    "Mike Wahler" <> wrote:

    > "sandy" <> wrote in message
    > news:...
    > > Hey guys,
    > >
    > > I know this is silly, but I just wanted to take some break from work. I
    > > was just wodering if its possible to write a c++ program that can print
    > > "iloveyou" in shape of 'heart' when executed.

    >
    > Certainly.
    >
    > > The impotant thing is

    >
    > Don't say that on Valentine's Day. :)
    >
    > > that, the program should not show any kind of words related to it, i
    > > mean the program should not be understandable at the very first sight
    > > the user goes through the code. It will be gr8 if something more
    > > creative is achieved out of this idea. Think about it. Let me know if
    > > its possible to make a code that can interact with user and print the
    > > results for just one particular kind of input, and print it in a
    > > beautiful way. I am not good enough in c++ to do that, so i was just
    > > wondering someone can help me out with it. Thank you.

    >
    > Get some graph paper, and draw the characters (perhaps asterisks) of
    > the output. After that it should be simple to write some loops to
    > output various character sequences. If you want to further obfuscate
    > the source, put random amounts of it in separate functions.


    You could also build the "i love you" string from ascii values or
    individual chars that are distributed in the code.

    --
    Magic depends on tradition and belief. It does not welcome observation,
    nor does it profit by experiment. On the other hand, science is based
    on experience; it is open to correction by observation and experiment.
    Daniel T., Feb 7, 2006
    #3
  4. sandy

    red floyd Guest

    sandy wrote:
    > Hey guys,
    >
    > I know this is silly, but I just wanted to take some break from work. I
    > was just wodering if its possible to write a c++ program that can print
    > "iloveyou" in shape of 'heart' when executed. The impotant thing is
    > that, the program should not show any kind of words related to it, i
    > mean the program should not be understandable at the very first sight
    > the user goes through the code. It will be gr8 if something more
    > creative is achieved out of this idea. Think about it. Let me know if
    > its possible to make a code that can interact with user and print the
    > results for just one particular kind of input, and print it in a
    > beautiful way. I am not good enough in c++ to do that, so i was just
    > wondering someone can help me out with it. Thank you.
    >
    > sandy
    >


    Go to www.ioccc.org, they may have something similar. I know they have
    stuff that does circles with pi....
    red floyd, Feb 7, 2006
    #4
  5. sandy

    jjcp Guest

    hey just a thought you could type cast the int nubers of the charaters
    you want to print out. that should be fun :)
    Daniel T. wrote:
    > In article <mDSFf.10811$>,
    > "Mike Wahler" <> wrote:
    >
    >
    >>"sandy" <> wrote in message
    >>news:...
    >>
    >>>Hey guys,
    >>>
    >>>I know this is silly, but I just wanted to take some break from work. I
    >>>was just wodering if its possible to write a c++ program that can print
    >>>"iloveyou" in shape of 'heart' when executed.

    >>
    >>Certainly.
    >>
    >>
    >>>The impotant thing is

    >>
    >>Don't say that on Valentine's Day. :)
    >>
    >>
    >>>that, the program should not show any kind of words related to it, i
    >>>mean the program should not be understandable at the very first sight
    >>>the user goes through the code. It will be gr8 if something more
    >>>creative is achieved out of this idea. Think about it. Let me know if
    >>>its possible to make a code that can interact with user and print the
    >>>results for just one particular kind of input, and print it in a
    >>>beautiful way. I am not good enough in c++ to do that, so i was just
    >>>wondering someone can help me out with it. Thank you.

    >>
    >>Get some graph paper, and draw the characters (perhaps asterisks) of
    >>the output. After that it should be simple to write some loops to
    >>output various character sequences. If you want to further obfuscate
    >>the source, put random amounts of it in separate functions.

    >
    >
    > You could also build the "i love you" string from ascii values or
    > individual chars that are distributed in the code.
    >
    jjcp, Feb 7, 2006
    #5
  6. sandy

    sandy Guest

    Thank you guys, i will check out every advise u guys have me. thank
    you,

    Sandy

    sandy wrote:
    > Hey guys,
    >
    > I know this is silly, but I just wanted to take some break from work. I
    > was just wodering if its possible to write a c++ program that can print
    > "iloveyou" in shape of 'heart' when executed. The impotant thing is
    > that, the program should not show any kind of words related to it, i
    > mean the program should not be understandable at the very first sight
    > the user goes through the code. It will be gr8 if something more
    > creative is achieved out of this idea. Think about it. Let me know if
    > its possible to make a code that can interact with user and print the
    > results for just one particular kind of input, and print it in a
    > beautiful way. I am not good enough in c++ to do that, so i was just
    > wondering someone can help me out with it. Thank you.
    >
    > sandy
    sandy, Feb 7, 2006
    #6
  7. sandy

    sandy Guest

    Thank you guys, i will check out every advise u guys have gave me.
    thank you,

    Sandy

    sandy wrote:
    > Hey guys,
    >
    > I know this is silly, but I just wanted to take some break from work. I
    > was just wodering if its possible to write a c++ program that can print
    > "iloveyou" in shape of 'heart' when executed. The impotant thing is
    > that, the program should not show any kind of words related to it, i
    > mean the program should not be understandable at the very first sight
    > the user goes through the code. It will be gr8 if something more
    > creative is achieved out of this idea. Think about it. Let me know if
    > its possible to make a code that can interact with user and print the
    > results for just one particular kind of input, and print it in a
    > beautiful way. I am not good enough in c++ to do that, so i was just
    > wondering someone can help me out with it. Thank you.
    >
    > sandy
    sandy, Feb 7, 2006
    #7
  8. sandy

    Jerry Coffin Guest

    sandy wrote:
    > Hey guys,
    >
    > I know this is silly, but I just wanted to take some break from work. I
    > was just wodering if its possible to write a c++ program that can print
    > "iloveyou" in shape of 'heart' when executed. The impotant thing is
    > that, the program should not show any kind of words related to it, i
    > mean the program should not be understandable at the very first sight
    > the user goes through the code. It will be gr8 if something more
    > creative is achieved out of this idea. Think about it. Let me know if
    > its possible to make a code that can interact with user and print the
    > results for just one particular kind of input, and print it in a
    > beautiful way. I am not good enough in c++ to do that, so i was just
    > wondering someone can help me out with it. Thank you.


    One minor point: you've gotten a couple of hints to embed the string as
    hex, decimal, etc. numbers in your source code. While this can
    obfuscate the source code itself (a little) it has no effect on the
    executable -- there the string will stil show up just as if you'd
    written it normally.

    There are quite a few ways of making it harder to understand. For
    example, you could use what is probably the oldest cipher known to man
    -- just subtract 3 (or whatever) from each number in the string, and
    then add 3 to each character as you print it out.

    If you want to make it a bit more complex, you can use a slightly more
    complex cipher -- for example, use two strings, and XOR the characters
    together as you print them out.

    OTOH, instead of obfuscating the string, you could just obfuscate the
    code. For example, something like this might be a start in the right
    general direction:

    #include<iostream>

    char *c[] = { "HILO", "NOTYOU", "TRI", "SHOVE" };
    char **cp[] = { c+3, c+2, c+1, c };
    char ***cpp = cp;

    int main() {
    std::cout << **++cpp+2;
    std::cout << *--*++cpp+2;
    std::cout << *cpp[-2]+3;
    std::cout << cpp[-1][-1]+3;
    return 0;
    }

    Obfuscation doesn't require #define's!

    --
    Later,
    Jerry.
    Jerry Coffin, Feb 7, 2006
    #8
  9. sandy

    Guest

    sandy wrote:
    > Hey guys,
    >
    > I know this is silly, but I just wanted to take some break from work. I
    > was just wodering if its possible to write a c++ program that can print
    > "iloveyou" in shape of 'heart' when executed. The impotant thing is
    > that, the program should not show any kind of words related to it,


    Here's a start...
    I didn't make much effort in hiding the string though. But otherwise it
    should be pretty hard to figure out. Compiles without warning on GCC
    3.4.4 with -W -Wall -pedantic.

    --- snipp ---
    #include <iostream>
    #include <string>
    int main(){std::string g=" I LOVE C++!";
    char t[]={0x15,0x0C,0x3F,0x0F,0xE3,0xFC,0xFF,0xBF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0xF8,
    0xFF,0xFF,0x83,0xFF,0xF8,0x07,0xFF,0x00,0x1F,0xF0,
    0x00,0x3E,0x00,0x00,0x40,0x00};char w=t[0],x=w,h=
    t[1],y=h,l=g.length();unsigned i=0;while(y--){x=w;
    while(x--){unsigned b=2+i/8,o=7-i%8;std::cout<<(t[
    b]&(1<<o)?g[i%l]:' ');i++;}std::cout<<"\n";}}
    --- /snipp ---

    Cheers,
    Andre
    , Feb 7, 2006
    #9
  10. sandy

    sandy Guest

    Hi guys,

    Very good ideas guys, you helped me get started. Thank you very much.

    sandy

    sandy wrote:
    > Hey guys,
    >
    > I know this is silly, but I just wanted to take some break from work. I
    > was just wodering if its possible to write a c++ program that can print
    > "iloveyou" in shape of 'heart' when executed. The impotant thing is
    > that, the program should not show any kind of words related to it, i
    > mean the program should not be understandable at the very first sight
    > the user goes through the code. It will be gr8 if something more
    > creative is achieved out of this idea. Think about it. Let me know if
    > its possible to make a code that can interact with user and print the
    > results for just one particular kind of input, and print it in a
    > beautiful way. I am not good enough in c++ to do that, so i was just
    > wondering someone can help me out with it. Thank you.
    >
    > sandy
    sandy, Feb 7, 2006
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GHUM
    Replies:
    0
    Views:
    223
  2. k.sahici
    Replies:
    3
    Views:
    283
    Roedy Green
    Apr 14, 2008
  3. Andy
    Replies:
    1
    Views:
    670
  4. Replies:
    2
    Views:
    255
  5. Rob Redmon

    Convert day of year to month, day

    Rob Redmon, Apr 4, 2008, in forum: Ruby
    Replies:
    7
    Views:
    276
    Alex Wayne
    Apr 4, 2008
Loading...

Share This Page