|
can anyone expain this logic flow!i mean the for loop makes no sense to me!...yet it works!and displays the map of india!
#include <stdio.h>
main()
{
int a,b,c;
int count = 1;
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;
}
-- modified at 5:22 Wednesday 25th January, 2006
|
|
|
|
|
|
|
|
First shot:
namaskaaram wrote: 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!"
This is the map of india, XORed with some easy key.
namaskaaram wrote: for(; a-- > 64 ; )
putchar ( ++c=='Z' ? c = c/ 9:33^b&1); return 0;
This displays spaces or '!', ++c=='Z' ? c = c/ 9:33^b&1 being the decyphering code.
More in a while...
~RaGE();
|
|
|
|
|
Rage wrote: This displays spaces or '!', ++c=='Z' ? c = c/ 9:33^b&1 being the decyphering code.
we have a ?: operator here, so might be seen this way first :
putchar(
(++c == 'Z') ?
(c = c / 9) :
(33 ^ (b & 1))
);
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
More as promised:
namaskaaram wrote: 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 each step in this for loop:
1. b is increased by one in [b+++21], so you basically do b=10, b=11, b=12, and so on.
2. a is initialised to the value of the char placed in position b+21 as stated in [b+++21] in the map string.
3. the second for loop is executed. Let's have a closer look:
++c=='Z' ? c = c/ 9:33^b&1
this is equivalent to
if (c==30)
putchar(c=c/9);
else
putchar(33^b&1);
c++;
following happens in the for loop
3a. a is decreased by one, meaning you stay in this loop (a-64) times
3b. c is increased. If c is equal to 'Z'(=30), a return to carriage is printed, since ++c=='Z' ? c = c/ 9:33^b&1 returns c = c/9, and this is 10.
3c. otherwise, you return 33 Xored with b&1 which is either a space or a '!' char, which prints the map.
when the index b+21 exceeds the string length, the assignement a = string[b+21]is false, leaving the first for loop.
and finally, int count = 1; is of no use
Hope this helps.
~RaGE();
-- modified at 6:03 Wednesday 25th January, 2006
|
|
|
|
|
Rage wrote: if (c==30)
Is actually:
if (c == 90) thus dividing by 9 would yield 10, a newline character;
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
this is how we could see it in a better view :
<font color=blue>#include</font> <stdio.h>
<font color=blue>int main</font>(<font color=blue>void</font>) {
<font color=blue>int</font> a = 0,
b = 10,
c = 10; <font color=green>
<font color=blue>char</font>* pszMap =
<font color=gray>"- 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!"</font>;
a = pszMap[b+21];
b++;
<font color=blue>while</font> (a != <font color=gray>'\0'</font>) {
<font color=blue>while</font> (a > 64) {
a--;
c++;
<font color=blue>if</font> (c == 'Z') {
c /= 9;
putchar(c);
}
<font color=blue>else</font> {
putchar(33 ^ (b & 1));
}
}
a = pszMap[b+21];
b++;
}
<font color=blue>return</font> 0;
}
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
|
|
toxcct wrote: i love that sort of tests
me too
#include "stdio.h"
main()
{
int b=0,c=0,q=60,_=q;for(float i=-20,o,O=0,l=0,j,p;j=O*O,p=l*l,
(!_--|(j+p>4)?fputc(b?q+(_/3):10,(i+=!b,p=j=O=l=0,c++,stdout)),
_=q:l=2*O*l+i/20,O=j-p+o),b=c%q,c<2400;o=-2+b*.05);
}
...
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
|
|
|
yes, it will work.
i forget how i worked that thing out, but i think the o gets initialized before its value is ever used for anything meaningful.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
ahh , i did not look correctly...
in for(float i=-20,o,O=0,l=0,j,p;j=O*..... , o is defined as a float, such as i, O, l, j, p...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
i don't have any compiler there, so tell me if i'm wrong :
<font color=blue>#include</font> <font color=gray>"stdio.h"</font> <font color=green>
<font color=blue>void main</font>(<font color=blue>void</font>) {
<font color=blue>int</font> b = 0,
c = 0,
q = 60,
_ = q;
<font color=blue>float</font> i = -20,
o = 0,
O = 0,
l = 0,
j = 0,
p = 0;
<font color=blue>do</font> {
j = O * O;
p = l * l;
<font color=blue>if</font> ((!_) | ((j+p) > 4)) {
i += !b;
p = j = O = l = 0;
<font color=blue>if</font> (b != 0) {
fputc((q + (_ / 3)), <font color=blue>stdout</font>);
}
<font color=blue>else</font> {
fputc(10, <font color=blue>stdout</font>);
}
c++;
}
<font color=blue>else</font> {
l = (2 * O * l) + (i / 20);
O = j - p + o;
}
_--;
b = c % q;
o = -2 + b * 0.05;
} <font color=blue>while</font> (c < 2400);
}
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
|
|
|
even I tooooooooo
never say die
|
|
|
|
|
toxcct wrote: i love that sort of tests
Well here is another one,
Writen in the wee hours of the morning
??=define _i_ int
??=define _i (??/
_i_
??=include<stdio.h>
_i_ main ??/
_i ??/
__i, char* ??/
i_??/
??(??/
??))
??=define _endl_ ;
??<char _s??/
??(9??/
??), _i__??/
??(4??/
??) _endl_
??=define _s_ _endl_ _s
??<_s_ ??/
??(0??/
??) = '??/
??=' _s_ ??/
??(1??/
??) = '??/
??(' _s_ ??/
??(2??/
??) = '??/
??/??/' _endl_
??=define _m_(m_) ? m_ :
??>_s_ ??/
??(3??/
??) = '??/
??)' _s_ ??/
??(4??/
??) = '??/
??'' _s_ ??/
??(5??/
??) = '??<' _endl_
??=define _START(s) for _i __i__ = s _endl_
??<_i_ e = (__i == 2) ? (((*i_??/
??(1??/
??)-0x30) < 0) ??/
??!??/
??! ((*i_??/
??(1??/
??)-0x30) > 9)) _m_(9) (*i_??/
??(1??/
??)-0x30): 9 _endl_
??=define _VALIDATE(v) __i__ < e _endl_ __i__++)
??<_s_ ??/
??(6??/
??) = '??/
??!' _s_ ??/
??(7??/
??) = '??/
??>' _s_ ??/
??(8??/
??) = '??-' _endl_
??>
??=define move_to(n) case n:
??<_START(0) _VALIDATE(0)
??=define skip ) _endl_ break _endl_
??<switch (__i__)
??< move_to(0)
??=define to_mem sprintf (_i__,
??<to_mem "??/
???/?=" skip
??> move_to(1)
??=define _do_i_ "%d. "
??< to_mem "??/
???/?(" skip
??>move_to(2)
??< to_mem "??/
???/?/" skip
??> move_to(3)
??< to_mem "??/
???/?)" skip
??=define move_screen printf (
??=define show_single(i) , _s ??/
??(i??/
??)
??=define _char_ " %c"
??>move_to(4)
??< to_mem "??/
???/?'" skip
??> move_to(5)
??< to_mem "??/
???/?<" skip
??=define _endl_null_ return 0 _endl_
??>move_to(6)
??< to_mem "??/
???/?!" skip
??> move_to(7)
??< to_mem "??/
???/?>" skip
??=define _text_ " %s means "
??>move_to(8)
??< to_mem "??/
???/?-" skip ??>
??>move_screen _do_i_ "_text_"_text_"_char_"_char_"??/
??/n", __i__, _i__ show_single (__i__)) _endl_
??>
??>
??> _endl_null_
??>
Have fun
codito ergo sum
|
|
|
|
|
of course, we have to know the C++ compiler digrams/trigrams... which i actually don't know by heart, and hope i'll never have to code this way !!!
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
We discovered the excistance of trigraphs during an assembly analysing session
trying to figure why this d*mned compiler didn't something completly different
than designed to
codito ergo sum
|
|
|
|
|