Article count:948 Read by:3148873

Account Entry

After reading these C language examples, you must be like me and say 5 "wow"s!!!!

Latest update time:2024-10-22
    Reads:

Example 1

First, let's see how the master calculated pi.

#include <stdio.h>
long a=10000,b=0,c=10000,d,e,f[10001],g;
void main()
{
    for(;b != c; f[b++] = a/5);
    for(; d=0,g=c*2,c>5000; c--,printf('%.4d',e+d/a),e=d%a)
    for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b); 

Execution Result:

Teacher Peng is really at a loss for words.

first

Example 2

Simulate the Fibonacci sequence printed by a Turing machine

#include <stdio.h>
#define f int
#define v (void)printf(
#define x ),exit(1);
#define y ){if(n)c=z(n,u),u=n,n=c;o[i]=n?'0'+(1&*n):'0';}
#define z(a,b) (f*)(~1&*a^(f)b)
#define k(l) if(!(l=(f*)malloc(sizeof(l))))v 23+m x if(1&(f)l)v 39+m x*l=
r(p,q,d)f*p,*q;{char o[81];f*n=p,i=39,*c,*u=d?q:z(p,q);o[40]='0'+(1&*p);
for(;i>=0;i--y u=d?z(p,q):q;n=p;for(i=41;i<79;i++y o[i++]='\r';o[i++]=0;
v o);(void)fflush(stdout);sleep(1);}
main(a,c)char**c;{char*u,*malloc(),*m=
'Usage: black [string]\n\0No more memory\n\0Unusable memory alignment\n\0jt,s@m@ (beleY%XX&Yz {z&z}i|R(|)*((.)i)hiniFiGJ%FG.JJgJ: ;;&;z {z&z}-RS/ROiOV OP+PsaPh+ijainnjmamfmfAlnnnnphppopv%vvgv.aABiB1/BVP11/1.%..&.OhrR-WV V1#1VP1CcC0R\
\n\n'CVP0\n!\n\n'\nEaEEnEamat!akckk'kwaww'wz,zzozEit +'
,
*n=m;f*q,*p=0,*g,b=3,d;
if(a>2)v m x n=a>1?c[1]:n;
/*v'\t\t\t\t\tV\n');*/
k(q)0;u=n;a=~1&'j';
while(a!='x'){
 /*r(q,p,b);*/
 for(;;u+=3){
  u= *u?u:n;
  if((~1&*u)==a&&(1&*q)<<1==(2&u[2]))break;
 }
 a=~1&u[1];
 d=(8&u[2])>>3;
 if(16&u[2])putchar(u[3]);
 if(4&u[2])*q|=1;else*q&=~1;
 if(b==d)g=p;else{
  g=z(q,p);
  if(!g){k(g)(f)q;*q^=(f)g;}
 }
 p=q;q=g;b=1-d;
}
/*r(q,p,b);v'\n');*/exit(0);
}

Execution Result:

double sink

Example 3

Look at the following code,

At first glance I thought it was a copy error.


#include <stdio.h>
main(int t,int _,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);
}

But this code has no problem and can be compiled.

Execution Result:


Treble

The result of the execution turned out to be a poem!

The author is Ian Phillipps .


Example 4

This little train, full of performance art, has made Zhong Yi start to completely doubt his life!

quadra what the hell!


The results are as follows:

peng@ubuntu:~/test$ ./marshall 
      choo choo

Example 5

If you still think it’s just so so, then take a look at the following code, which is simply a perfect combination of art and code.

I believe the author of this code must be a greasy, fat, otaku with a full beard ,

Otherwise, how could one draw such a shocking, world-shaking, incredibly beautiful, and so kawaii little loli!


The key is that he can actually run:

The painting turned out to be snowflakes!

Penta


These codes are some winning works of IOCCC [The International Obfuscated C Code Contest (International C Code Contest) is an international programming competition]. If you are interested, you can search for it.

There is no doubt that these masters are the world's top C language programmers, all god-like and legendary.

We will not discuss the principles of these codes here (you can search the Internet for analysis of these codes) .

Zhongyi is not encouraging everyone to write such code.

On the contrary, what I want to tell you is:

If a master writes code like this, it's a classic. If you write code like this, it's garbage!

So between trash and classic, you need to make a choice.

The C language is profound and extensive. Dear programmers, learn it and cherish it!



Autumn The recruitment has already begun. If you are not well prepared, Autumn It's hard to find a good job.


Here is a big employment gift package for everyone. You can prepare for the spring recruitment and find a good job!



Latest articles about

 
EEWorld WeChat Subscription

 
EEWorld WeChat Service Number

 
AutoDevelopers

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building,Block B, 18 Zhongguancun Street, Haidian District,Beijing, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号