Click to See Complete Forum and Search --> : Does anyone have any good rountines?
Sam Finch
Nov 30th, 2000, 06:14 AM
to do what in particular?
parksie
Nov 30th, 2000, 12:32 PM
This one rocks, considering the current season:
#include <stdio.h>
main(t,_,a)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(31[a]):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);}
Benjamin
Nov 30th, 2000, 01:57 PM
tried compiling in borland, Dev C++, and VC++ 6
I got 5 errors with Dev C++ and VC++ and 12 with borland :eek:
Benjamin
Nov 30th, 2000, 02:03 PM
Ok, I compiled as a C project in Dev C++ and it worked, but the console closed so fast I couldn't read it...
BTW Chimp:
I have a few math routines I have that you may like?
Distance Formula
Factorial
and random numbers
I also have a routine that draws a line out of any character...
and any length, and any position on the console window :)
let me know,
Dennis
parksie
Nov 30th, 2000, 04:06 PM
Dennis - run the program in a console window, then you'll see.
HarryW
Nov 30th, 2000, 04:08 PM
Any idea how to get it to compile in VC++ 6?
parksie
Nov 30th, 2000, 04:16 PM
Make sure it's in a file with a .c extension, not .cpp - then it'll work.
Benjiman, sure, i try em!
Vlatko
Dec 3rd, 2000, 10:48 AM
I am wondering how does parksie's routine work. All i see are some weird signns.
HarryW
Dec 3rd, 2000, 11:15 AM
Hey cool :) The code looks like complete gibberish though. Almost as bad as Befunge.
parksie
Dec 3rd, 2000, 11:20 AM
It seems like it's recursively calling main(). I'll have a go at 'decoding the code'...as it were :D
I may be gone some time ;)
Sam Finch
Dec 3rd, 2000, 11:58 AM
it looks like the code is mainly taken up by strings
#include <stdio.h>
main(t,_,a)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,
//a big string
"@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(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1)
:0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
//a smaller string
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"
),a+1);
I would guess that the big string is an encrypted form of the verses, and its decrypted by the code.
Benjamin
Dec 3rd, 2000, 01:19 PM
sorry it took so long, I forgot all about this thread!
these aren't really functions, they are whole programs, but can be easily modified and put into a function
compliment and suppliment:
/*
Copyright © 2000 Dennis Wrenn
Please do not steal this code and
claim it as your own, if you have to
do that, you must be one pathetic fool.
denniswrenn@yahoo.com
Code written in notepad,
compiled in Borland Turbo C++ 4.5
*/
#include <iostream.h>
int main()
{
int choice;
int angle;
int comp, sup;
do
{
cout << "Find the compliment(1), or the supplement(2)?: ";
cin >> choice;
}while(choice < 1 || choice > 2);
cout << "Please enter the angle: ";
cin >> angle;
comp = 90 - angle;
sup = 180 - angle;
switch (choice)
{
case 2:
cout << "The Suppliment of " << angle << " is " << sup;
break;
case 1:
cout << "The Compliment of " << angle << " is " << comp;
break;
}
return 0;
}
distance:
/*
Copyright © 2000 Dennis Wrenn
Please do not steal this code and
claim it as your own, if you have to
do that, you must be one pathetic fool.
denniswrenn@yahoo.com
Code written in notepad,
compiled in Borland Turbo C++ 4.5
*/
#include <iostream.h>
#include <math.h>
int main(void)
{
cout.setf(ios::fixed);
double x1;
double y1;
double x2;
double y2;
double d;
cout.precision(2);
//X1
cout << "Please enter the coordinate point for X1: ";
cin >> x1;
//Y1
cout << "Please enter the coordinate point for Y1: ";
cin >> y1;
//X2
cout << "Please enter the coordinate point for X2: ";
cin >> x2;
//Y2
cout << "Please enter the coordinate point for Y2: ";
cin >> y2;
/*
distance formula =
____________________________
|/ (X2 - X1)^2 + (Y2 - Y1) ^ 2
*/
d = sqrt( (pow((x2 - x1),2)) + (pow((y2 - y1),2)) );
cout << "The Distance between the points you entered are: ";
cout << d;
return(0);
}
factorial:
/*
Copyright © 2000 Dennis Wrenn
Please do not steal this code and
claim it as your own, if you have to
do that, you must be one pathetic fool.
denniswrenn@yahoo.com
Code written in notepad,
compiled in Borland Turbo C++ 4.5
*/
#include <iostream.h>
int main()
{
int number = 0; //the number to be fractaled
int count = 0; //counter variable
double fractal = 1; //The end number needs to have large available
//memory incase
//somebody enters a large number
do
{
cout << "Please enter a number greater than 0 and \n"
<< "less than 170: "; //input
cin >> number; //idiot proof loop, don't want a negative number
cout << endl; // entered
//if the number is >170 then there will be an overflow
} while (number <= 0 || number >=171);
for(count = 1; count <= number; count++)
{
cout << fractal << " * " << count; //main processing loop
fractal *= (double)count;
cout << " = " << fractal << endl;
}
cout << endl;
cout << number << "!" << " = " << fractal; //output
return 0; //return nothing to indicate 0 errors occured
}
#include <random.h>
#include <iostream.h>
int main()
{
randomize();
int r = random(100); // generates #'s between 0 - 99
r++; // we want 1 - 100
cout << r << endl;
return 0;
}
the last one isn't much... just a little thing I threw together...
[Edited by Benjamin on 12-03-2000 at 02:27 PM]
parksie
Dec 3rd, 2000, 01:22 PM
compliment and suppliment
Complement and Supplement ;)
Benjamin
Dec 3rd, 2000, 01:30 PM
:rolleyes:
HarryW
Dec 3rd, 2000, 01:35 PM
Yes, I picked the code apart too a while ago. The bit I didn't understand was this:
main(t,_,a)char *a;
I thought C was strongly typed - what are t, _ and a? And what's "char *a" got to do with it?
parksie
Dec 3rd, 2000, 03:06 PM
That's the old-style formal definition:
void main(argc, argv)
int argc;
char **argv;
{
// ...
}
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.