Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Google AI PRO - 18 Month
Sanathbh
Updated:
Today at 2:42 PM
Ad icon
Singapore V2Ray VPN for Tunneling
hu KANNA
Updated:
Monday at 9:03 PM
Plan your Crypto & Forex entries before you take the trade
romeshnonis
Updated:
Monday at 3:20 AM
RHCSA, RHCE, AWS, Docker, Kubernetes Training
Sanjeewani95
Updated:
Sep 8, 2026
🛡️ Kaspersky Antivirus – 1 Year / 1 Device | Rs. 2,300 | Only 9 Left
KSPathirana
Updated:
Sep 7, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
C++ Programming (Direct Insert Sort upgrade)
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="madurax86" data-source="post: 3672219" data-attributes="member: 1293"><p>i took the actual theory from cow_theboy's thread <img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /></p><p>i upgraded it abit this one would run faster</p><p></p><p>[CODE]#include <stdio></p><p>#include <iostream></p><p></p><p>int arr[10];</p><p></p><p>int flip(int i, int j){ //function to shift array values</p><p> int g;</p><p> g=arr[i];</p><p> arr[i]=arr[j];</p><p> arr[j]=g;</p><p>}</p><p>int main(){</p><p> //initialization</p><p> int i,j,kh,ih;</p><p> arr[0]=5;</p><p> arr[1]=1;</p><p> arr[2]=3;</p><p> arr[3]=2;</p><p> arr[4]=10;</p><p> arr[5]=8;</p><p> arr[6]=7;</p><p> arr[7]=4;</p><p> arr[8]=9;</p><p> arr[9]=6;</p><p> //sorting</p><p> for (i=0;i<10;i++){</p><p> kh=0; //lowest number to start with</p><p> for (j=i;j<10;j++){</p><p> if (kh < arr[j]){kh = arr[j]; ih=j;} //check for the max in sub list</p><p> }</p><p> flip(ih,i); //change the values</p><p> }</p><p></p><p> for (i=0;i<10;i++) cout<<arr[i]<<endl; //print out the sorted list</p><p> cin>>j; //just to stop the terminal from exiting</p><p> return 0;</p><p>}[/CODE]</p></blockquote><p></p>
[QUOTE="madurax86, post: 3672219, member: 1293"] i took the actual theory from cow_theboy's thread :P i upgraded it abit this one would run faster [CODE]#include <stdio> #include <iostream> int arr[10]; int flip(int i, int j){ //function to shift array values int g; g=arr[i]; arr[i]=arr[j]; arr[j]=g; } int main(){ //initialization int i,j,kh,ih; arr[0]=5; arr[1]=1; arr[2]=3; arr[3]=2; arr[4]=10; arr[5]=8; arr[6]=7; arr[7]=4; arr[8]=9; arr[9]=6; //sorting for (i=0;i<10;i++){ kh=0; //lowest number to start with for (j=i;j<10;j++){ if (kh < arr[j]){kh = arr[j]; ih=j;} //check for the max in sub list } flip(ih,i); //change the values } for (i=0;i<10;i++) cout<<arr[i]<<endl; //print out the sorted list cin>>j; //just to stop the terminal from exiting return 0; }[/CODE] [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom