Jump to content

Guess this code, win a prize!


PlanetCpp

Recommended Posts

ok there no prize.. sorry. still want to try?

ok try not to use the compiler of course just try to follow what it's doing, i won't add the inputted data, unless noone gets it then ill write the whole program. this is a one-liner i wrote last year.

 

/////code

for(i=0,x=1;i<arraysize,x<arraysize;i++,x++){if(arry>arry[x]){arry[x]^=arry;arry^=arry[x];arry[x]^=arry;}if(x<(arraysize-1)){i--;}else{x=i+1;}}

/////end code

:confused: ?

Link to comment
Share on other sites

#include <iostream>

using std::cout;

using std::cin;

using std::endl;

 

int main()

{

int i,x,arraysize=0,tmp=0;

int arry[50]={0}; //initiate array of 50 integers

cout<<"Enter in integer values, use negative # to stop\n";

cin>>tmp;

while(tmp>=0) //loop till # is negative

{

arry[arraysize]=tmp;

arraysize+=1; //increment counter

cin>>tmp;

}

for(i=0,x=1;i<arraysize,x<arraysize;i++,x++){if(arry>arry[x]){arry[x]^=arry;arry^=arry[x];arry[x]^=arry;}if(x<(arraysize-1)){i--;}else{x=i+1;}}

for(i=0;i<arraysize;i++) //show array

cout<<arry<<endl;

return 0;

}

Help?

Link to comment
Share on other sites

  • 2 months later...

15 lines???

the original code I put was one line, thats why im saying guess this code.

it's a bubble sort algorithm written on one line, the other post was just a small example so you can see what it's doing, if thats the program your talking about then it's more then 15 lines anyway but it doesn't matter now does it.

Link to comment
Share on other sites

  • 7 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.