Guest User

Untitled

a guest
Jan 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. int main()
  2. {
  3. string arnList[9]={"John", "Dave", "Steve", "Kevin","Andrew","Scott","Colin","Timothy","Zenon"};
  4. int nLength=9;
  5. string nTemp;
  6. int iCv;
  7. for (iCv = 1; iCv < nLength; ++iCv)
  8. {
  9. //the new value to be inserted into a temporary location
  10. nTemp = arnList[iCv];
  11. // k is the index of the number to the left of the iCv.
  12. int k;
  13. for (k = iCv-1; k >= 0 && arnList[k] > nTemp; k--)
  14. {
  15. arnList[k+1] = arnList[k];
  16. }
  17. arnList[k+1] = nTemp;
  18. }
  19. for(iCv=0;iCv<nLength;iCv++) cout<<arnList[iCv]<<" ";
  20. cout<<endl;
  21. return 0;
  22. }
Add Comment
Please, Sign In to add comment