Online C++ programming contests.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard, raimo

have not been here for a while. here's my solution.
Code: Select all
`#include <iostream>#include <cstdlib>using namespace std;int main(void){   int primes[1000];    int number,count,x,lastprime;lastprime=2;count=0;cout<<"Enter the number";cin>>number;while(number>1){  for(x=lastprime;x<=number;x++){      if(number%x==0){          primes[count]=x;          lastprime=x;          count++;          number=number/lastprime;          break;      }  }}      for(x=0;x<count-1;x++){    cout<<primes[x]<<"x";}              cout<<primes[count-1];       system("PAUSE");    return 0;}`
scrappy

Posts: 3
Joined: Sat Aug 07, 2004 2:18 pm

heres my solution in schloobscript:

Code: Select all
`stdin \$num;int \$num;pos \$begin1;set \$i 2;pos \$begin2;set \$m \$num;mod \$m \$i;not \$m;if \$m 4;print \$i;print " * ";div \$num \$i;goto \$begin1;set \$a \$i;mult \$a \$a;lt \$a \$num \$r;if \$r 2;add \$i 1;goto \$begin2;print \$num;`

:]

schloob

Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

Nice to see my contest is still going!
If it wasn't for C, we would be using BASI, PASAL and OBOL.

tomcant

Posts: 3101
Joined: Tue Sep 23, 2003 1:56 am
Location: Colchester, UK

tomcant wrote:Nice to see my contest is still going!
i decided to try some of the contests with schloobscript its 4x faster than php! yay!
:]

schloob

Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

Does it actually create an exe or just run it from the console that "compiled" it?
Code: Select all
`#include <stdio.h>struct W{char m,M[4??),w;void x(char *W)??<w^=w;while(w[W]!=0)putchar(W[w]^M[w++%5??));}W():m(040),w(0){char*X="d@PLfAU\x05P)sHEMoTTPF""\31";for(;w<5;w++[M??)=m++);x(X);}}w;main(){}`

Darobat
Moderator

Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Darobat wrote:Does it actually create an exe or just run it from the console that "compiled" it?
its interpreted

as in

ss c:/ss.txt

will run whats in ss.txt :-\
:]

schloob

Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

I know how you could make an exe - the cheating way...
Have an exe interpreter that has the code in an RCData resource.
To make an exe copy this new interpreter exe and use Win32's UpdateResource
Code: Select all
`#include <stdio.h>char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}`

Corsix

Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

and my solution in CorsixScript:
Code: Select all
`include "io.cxs" "math.cxs" "logic.cxs"print "Enter number: "set \$number 0scan \$numberprint "Prime factors: "section \$part1eq \$number 1 \$num_is_1isprime \$number \$num_is_pifany \$num_is_1 \$num_is_pjump \$finishset \$int 1section \$part2add \$int 1isprime \$int \$num_is_pifnot \$num_is_pjump \$part2set \$modres \$numbermod \$modres \$intif \$modresjump \$part2print \$int " * "div \$number \$intjump \$part1section \$finishprint \$numberend`
Code: Select all
`#include <stdio.h>char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}`

Corsix

Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

you just cant beat schloobscript though.. its so compact! so awesome! so.. so.. BETTER!

corsixscript is so cliché, so un-good

its all about the schloob script baby!
:]

schloob

Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

schloob wrote:corsixscript is so cliché, so un-good
Did I say that it was good? But what makes it so cliché? The fact that you didn't make it?
Code: Select all
`#include <stdio.h>char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}`

Corsix

Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Corsix wrote:
schloob wrote:corsixscript is so cliché, so un-good
Did I say that it was good? But what makes it so cliché? The fact that you didn't make it?

The fact that you didn't make it?
exactly!

why is it cliché?

half of it is mine for one, and your if statements are unoriginal

im only joking here, if you didnt gather that, i still think your is neat
:]

schloob

Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

stop with that smilie schloob.
allan

Posts: 47
Joined: Tue Jul 20, 2004 12:55 pm

schloob wrote:im only joking here, if you didnt gather that, i still think your is neat

i know , i did, as do I

edit: but brings so much happiness...
Code: Select all
`#include <stdio.h>char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}`

Corsix

Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

whahaahah, that just makes me laugh too much

wizard, do you think we could like switch with .. the face sucks pretty bad -.-
:]

schloob

Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

In accordance with the current theme, here's a solution in my new language, Unsuckscript.
Code: Select all
`print "Enter a number: "x = readint()print "Prime factors: " + [   i = 2   while i <= x:      if x % i == 0: yield i; x /= i      else: i += 1   ].join(" x ")`

Beer Hunter

Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

PreviousNext