Announcement

Collapse
No announcement yet.

Thought this was interesting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I forgot to add:

    Re:
    main(t,_,a)
    char *a;
    {

    The declaration outside the brackets is a an old way of declaring globals.

    chuck
    Chuck
    秋音的爸爸

    Comment


    • #17
      Which hold a huge string. I just checked how much time that thing has to loop before writing the string and it's amasing. It loops 69606 times before having the correct string to write.

      Spazm
      P3-667@810 retail, Asus CUSL2-C, 2*128 mb PC-133(generic), G400DH 16mb, SBLive value, HollyWood+, 1*Realtek 8029(AS) and 1*Realtek 8039C, Quantum 30g, Pioneer DVD-115f

      Comment


      • #18
        You're right Chuck. You can do any recursive algorithm iteratively. I was wrong, not sure what I was thinking of at the time. Still, it doesn't mean that the iterative approach will be better.

        And I don't use the ternary much either, but it has it's uses. Some compilers can/will optimise it very effectively, and it has different precedence than if/then/else, which can improve the readability of some code (the example escapes me, but there's a classic in C where it cuts out a couple pairs of parentheses).
        Gigabyte P35-DS3L with a Q6600, 2GB Kingston HyperX (after *3* bad pairs of Crucial Ballistix 1066), Galaxy 8800GT 512MB, SB X-Fi, some drives, and a Dell 2005fpw. Running WinXP.

        Comment


        • #19
          Just noticed that ubb screwed with the code (so to speak )
          Not all of it shows above.
          Here is the complete text:

          <code>
          #include <stdio.h>
          main(t,_,a)
          char *a;
          {
          return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):
          1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
          main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
          "@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\
          ;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
          q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \
          ){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
          iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
          ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \
          }'+}##(!!/")
          :t<-50?_==*a?putchar(a[31]):main(-65,_,a+1):main((*a=='/')+t,_,a+1)
          :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
          "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);
          }

          </code>

          Last edited by cjolley; 15 August 2001, 13:48.
          Chuck
          秋音的爸爸

          Comment


          • #20
            I untangled all the ?: into if exept one.... the first one on the first line. It compile without error/waning but it only display the fisrt line of the string probably because the function loops without being able to reach the condition (that i have removed) to run backward and display the others.

            Spazm
            P3-667@810 retail, Asus CUSL2-C, 2*128 mb PC-133(generic), G400DH 16mb, SBLive value, HollyWood+, 1*Realtek 8029(AS) and 1*Realtek 8039C, Quantum 30g, Pioneer DVD-115f

            Comment


            • #21
              I'll see if I can find a copy I worked on.
              It ran correctly even if not all the ?: were converted.
              Maybe it will help.

              I don't think of programs like this a s looping.
              I think of them as diving down through the stack leaving bread-crumbs along the way so they can find their way back

              chuck
              Chuck
              秋音的爸爸

              Comment


              • #22
                It's ok, i just misplaced one of my else somewhere.
                Well even if there's no loop, it loop's in a way by recalling itself... but your right it's not a true loop.

                Spazm
                P3-667@810 retail, Asus CUSL2-C, 2*128 mb PC-133(generic), G400DH 16mb, SBLive value, HollyWood+, 1*Realtek 8029(AS) and 1*Realtek 8039C, Quantum 30g, Pioneer DVD-115f

                Comment


                • #23
                  Originally posted by spazm_1999
                  It's ok, i just misplaced one of my else somewhere....
                  Spazm
                  If you have it converted & working e-mail me the code please.
                  I'd like to play with it.
                  I don't get to do much with C anymore.
                  chuck
                  Chuck
                  秋音的爸爸

                  Comment


                  • #24
                    No problem.

                    Spazm
                    P3-667@810 retail, Asus CUSL2-C, 2*128 mb PC-133(generic), G400DH 16mb, SBLive value, HollyWood+, 1*Realtek 8029(AS) and 1*Realtek 8039C, Quantum 30g, Pioneer DVD-115f

                    Comment

                    Working...
                    X