Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- string arnList[9]={"John", "Dave", "Steve", "Kevin","Andrew","Scott","Colin","Timothy","Zenon"};
- int nLength=9;
- string nTemp;
- int iCv;
- for (iCv = 1; iCv < nLength; ++iCv)
- {
- //the new value to be inserted into a temporary location
- nTemp = arnList[iCv];
- // k is the index of the number to the left of the iCv.
- int k;
- for (k = iCv-1; k >= 0 && arnList[k] > nTemp; k--)
- {
- arnList[k+1] = arnList[k];
- }
- arnList[k+1] = nTemp;
- }
- for(iCv=0;iCv<nLength;iCv++) cout<<arnList[iCv]<<" ";
- cout<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment