Jump to content

Recommended Posts

Posted

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

Posted

#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...
Guest Syntax
Posted

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

Posted

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...
Posted

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.

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.