home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso
/
altsrc
/
articles
/
11363
< prev
next >
Wrap
Text File
|
1994-10-18
|
4KB
|
110 lines
Path: wupost!udel!news.mathworks.com!news.kei.com!yeshua.marcam.com!usc!howland.reston.ans.net!pipex!sunic!news.kth.se!admin.kth.se!merope.saaf.se!electra.saaf.se!not-for-mail
From: pausch@electra.saaf.se (Paul Schlyter)
Newsgroups: alt.sources
Subject: Re: Ugly code.
Date: 18 Oct 1994 05:56:37 +0100
Organization: Svensk Amat|rAstronomisk F|rening
Lines: 98
Message-ID: <37vki5$8el@electra.saaf.se>
References: <CxtEys.DKr@cs.dal.ca>
NNTP-Posting-Host: electra.saaf.se
In article <CxtEys.DKr@cs.dal.ca>,
Steve Franklin <franklin@ug.cs.dal.ca> wrote:
> This is some code for a solid-state assignment which computes the number
> of neighbors from a central atom that are sqrt(1), sqrt(2), etc... away
> from the central atom. Anyone able to make itany more compact or ugly?
> It needs the math library, and it's ansi C.
>
> #include<stdio.h>
> #include<math.h>
> typedef float f;typedef int Y;f p(f a,f b,f c){return sqrt(a*a+b*b+c*c);}
> f a,b,c;main(){Y i,j,k,X[9],n,V[9]={1,2,3,4,5,6,8,9,12};for(n=0;n<9;n++)
> {X[n]=0;}for(i=-2;i<3;i++)for(j=-2;j<3;j++)for(k=-2;k<3;k++){{{a=(f)i;b=(f)j;
> c=(f)k;for(n=0;n<9;n++){if(p(a,b,c)==(f)sqrt(V[n])){X[n]++;}}}}}for(n=0;n<9;
> n++){printf("N=%-2d #=%d\n",V[n],X[n]);}}
What about this? It's not more compact, but certainly more ugly!
#include<stdio.h>
#include<math.h>
#define ___ typedef
#defile main float
#define _ f
#define __ for
#define _____ printf
#define ____ main
#define ______ float
#define _______ int
#define ________ return
#define OO sqrt
#define O0 Y
#define OOO X
#define OO0 V
#define O0O if
#define O00 ,
#define OOOO ;
#define OOO0 (
#define OO0O )
#define OO00 {
#define O0OO }
#define O0O0 [
#define O00O ]
#define O000 "N=%-2d #=%d\n"
#define I 1
#define II 2
#define III 3
#define IV 4
#define V 5
#define VI 6
#define VII 7
#define VIII 8
#define IX 9
#define X 10
#define XI 11
#define XII 12
#define o a
#define oo b
#define ooo c
#define oooo *
#define ooooo +
#define oooooo ++
#define ooooooo n
#define oooooooo j
#define ooooooooo k
#define oooooooooo -
#define ooooooooooo =
#define oooooooooooo ==
#define ooooooooooooo i
#define oooooooooooooo <
#define ooooooooooooooo p
___ ______ _ OOOO ___ _______ O0 OOOO _ ooooooooooooooo OOO0 _ o O0O
_ oo O0O _ ooo OO0O OO00 ________ OO OOO0 o oooo o ooooo oo oooo oo
ooooo ooo oooo ooo OO0O OOOO O0OO _ o O0O oo O0O ooo OOOO ____ OOO0
OO0O OO00 O0 ooooooooooooo O0O oooooooo O0O ooooooooo O0O OOO O0O0 IX
O00O O0O ooooooo O0O OO0 O0O0 IX O00O ooooooooooo OO00 I O0O II O0O
III O0O IV O0O V O0O VI O0O VIII O0O IX O0O XII O0OO OOOO __ OOO0
ooooooo ooooooooooo 0 OOOO ooooooo oooooooooooooo IX OOOO ooooooo
oooooo OO0O OO00 OOO O0O0 ooooooo O00O ooooooooooo 0 OOOO O0OO __
OOO0 ooooooooooooo ooooooooooo oooooooooo II OOOO ooooooooooooo
oooooooooooooo III OOOO ooooooooooooo oooooo OO0O __ OOO0 oooooooo
ooooooooooo oooooooooo II OOOO oooooooo oooooooooooooo III OOOO
oooooooo oooooo OO0O __ OOO0 ooooooooo ooooooooooo oooooooooo II OOOO
ooooooooo oooooooooooooo III OOOO ooooooooo oooooo OO0O OO00 OO00
OO00 o ooooooooooo OOO0 _ OO0O ooooooooooooo OOOO oo ooooooooooo OOO0
_ OO0O oooooooo OOOO ooo ooooooooooo OOO0 _ OO0O ooooooooo OOOO __
OOO0 ooooooo ooooooooooo 0 OOOO ooooooo oooooooooooooo IX OOOO
ooooooo oooooo OO0O OO00 O0O OOO0 ooooooooooooooo OOO0 o O0O oo O0O
ooo OO0O oooooooooooo OOO0 _ OO0O OO OOO0 OO0 O0O0 ooooooo O00O OO0O
OO0O OO00 OOO O0O0 ooooooo O00O oooooo OOOO O0OO O0OO O0OO O0OO O0OO
__ OOO0 ooooooo ooooooooooo 0 OOOO ooooooo oooooooooooooo IX OOOO
ooooooo oooooo OO0O OO00 _____ OOO0 O000 O0O OO0 O0O0 ooooooo O00O
O0O OOO O0O0 ooooooo O00O OO0O OOOO O0OO O0OO
--
----------------------------------------------------------------
Paul Schlyter, SAAF (Swedish Amateur Astronomer's Society)
Nybrogatan 75 A, S-114 40 Stockholm, Sweden
InterNet: pausch@saaf.se psr@ausys.se