473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Anyone able to understand this C program?

Gurus,
One of my friend mailed me this sample piece of code:
#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;
}

I compiled the above program with visual studio and got a map of india
printed on the output screen.
I am underloss to understand how this program works.This seems cryptic
to me.Iam wondering whether those char in for loop of (b=c=10;a=....)
is ascii char?

This is not definitely a homework as some might think.Jus for my
curiosity would like to know abt this.

Advanced thanks for all your replys,
Regards,
s.subbarayan

Nov 15 '05 #1
1 2841
On 16 Sep 2005 06:44:46 -0700, "ssubbarayan" <ss****@gmail.com> wrote:
#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;
}

I compiled the above program with visual studio and got a map of india
printed on the output screen.
I am underloss to understand how this program works.This seems cryptic
to me.Iam wondering whether those char in for loop of (b=c=10;a=....)
is ascii char?


Talk about readable code...

(a) The values in the character string encode the length of blocks of
consecutive spaces or '!' as the difference between their value and
the character '@' (ASCII 64)

(b) The first line in the string is just to confuse the enemy. The
'[b++ + 21]' skips the firs 31 characters.

(c) 33^b&1 is equal to either ' ' or '!' depending if b is even or
odd. The actual value of b is meaningless.

(d) All the characters in the string less than '@' do not produce any
output, but some of them are necessary to keep the odd/even value of b
in sync.

(e) c is used as a column counter, running from 10 ('\n') to 90 ('Z'),
that is 80 columns. It fills a double role being sent as the newline
character every time it is reset to 10.

(f) count is not used.

A slightly less cryptic version follows.

#include <stdio.h>

#define MAX_COLUMN 81

char map_data[] =
"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!";

main()
{
int a,b;
int column;
char *map_ptr;

b = 0;
column = 1;

for (map_ptr = map_data;
a = *map_ptr;
map_ptr++
)
{
b = !b;
while (a-- > '@')
{
column++;
if (column == MAX_COLUMN)
{
putchar('\n');
column = 1;
}
else
{
if (b % 2)
{
putchar (' ');
}
else
{
putchar ('!');
}
}
}
}
}
Roberto Waltman

[ Please reply to the group, ]
[ return address is invalid. ]
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Leif K-Brooks | last post by:
Has anyone ever tried implementing a simple unstructured BASIC dialect in Python? I'm getting interested in language implementation, and looking at a reasonably simple example like that could be...
14
by: vic | last post by:
My manager wants me to develop a search program, that would work like they have it at edorado.com. She made up her requirements after having compared how search works at different websites, like...
11
by: JDeats | last post by:
1. Will there be different 64-bit .NET implementations for Intel and AMD 64-bit processors or will they share a common 64-bit CLR? 2. Will .NET managed code compiled for the 32-bit CLR be binary...
29
by: Roy Gourgi | last post by:
Hi, I am new to C#. I have the same time scheduling program written in C++ and it is 5 times faster than my version in C#. Why is it so slow as I thought that C# was only a little slower than...
11
by: ricolee99 | last post by:
Hi everyone, I'm trying to invoke my .exe application from a remote server. Here is the code: ManagementClass processClass = new ManagementClass ("\\\\" +"RemoteServerName" +...
31
by: Jim Hubbard | last post by:
I am downloading the REALbasic 5.5 demo and was just wondering if anyone else had tried it. I am tired of Microsoft constantly changing things and breaking backward compatibility ON PURPOSE. ...
13
by: Snis Pilbor | last post by:
Hello, Here is an idea I've been toying with to speed up programs but still keep them portable. It's just a very handwavey rough description right now since I haven't worked out details. The...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
13
by: Anonymous | last post by:
On MS site: http://msdn2.microsoft.com/en-us/library/esew7y1w(VS.80).aspx is the following garbled rambling: "You can avoid exporting classes by defining a DLL that defines a class with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.