PlanetCpp Posted July 16, 2002 Posted July 16, 2002 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 ?
PlanetCpp Posted July 19, 2002 Author Posted July 19, 2002 #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?
Guest Syntax Posted October 1, 2002 Posted October 1, 2002 Almost 15 lines of code, when it could've been alot less :-\
PlanetCpp Posted October 1, 2002 Author Posted October 1, 2002 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.
DJBruce Posted August 31, 2010 Posted August 31, 2010 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now