Jump to content

Guess this code, win a prize!

Featured Replies

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: ?

  • Author

#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?

  • 2 months later...

Almost 15 lines of code, when it could've been alot less :-\

  • Author

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.

  • 7 years later...

no prise?

 

As this thread is over 8 years old, and as the OP states, "ok there[sic] no prize" I am going to have to say with almost 100% certainty that there is no prize, nor is the OP even active on the site.

Archived

This topic is now archived and is closed to further replies.

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.