Encrypt/mess C source code

Source: Internet
Author: User
Tags printf

Previously published "6 Abnormal C language Hello World program" [Cool shell link] [csdn link], mainly is like everybody shows some C language of abnormal play. Also showed that the program can be written so that people do not understand, in that article, you can see a lot of people's message, a lot of people think it is fun, yes, it was used for friends "entertainment" for entertainment, the east, not too serious.

However, through this extreme writing, you can see that the source code can be written so complex and difficult to understand. Everyone may be laugh in admiration, and I hope that we can seriously think after the entertainment, you do not think we will not make the code so complicated, but not as extreme as the 6 Hello World, but, to tell the truth, Each of us has a clear program to make a mess of potential, but not the same level, I am not here to alarmist, everyone to take good of themselves.

The following is a step through step tutorial that teaches you how to make a clear code complex and difficult to understand. Of course, this is just a "concise tutorial". Or that sentence-"This article is for friends to" amuse themselves, if you want to feel interesting, the top sticker. If you don't think it's interesting, laugh. Just for fun, don't take it too seriously. ”

Normal procedure

Here is a program to find prime numbers:

void primes(int cap)
{
int i, j, composite;

for(i = 2; i < cap; ++i) {
composite = 0;
for(j = 2; j * j < i; ++j) {
composite += !(i % j);
}
if(!composite){
printf("%d\t", i);
}
}
}

int main()
{
primes(100);
}

Let's take a look at how to make this piece of code complex and difficult to understand.

First step, change for a while

In general, for the bad to follow is a bad one, the above program has a two for loop, we not only want to turn it into a while loop, but also to the double loop into a heavy loop, and then use a lot of if-else statements to judge.

void primes(int cap)
{
int i, j, composite, t = 0;

while(t < cap * cap) {
i = t / cap;
j = t++ % cap;
if(i <= 1);
else if(!j)
composite = j;
else if(j == i && !composite)
printf("%d\t",i);
else if(j > 1 && j < i)
composite += !(i % j);
}
}

int main()
{
primes(100);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.