View Single Post
Join Date: Jul 2008
Posts: 320
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 63
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

Re: Finding Positon of characters

 
0
  #5
Dec 2nd, 2008
Here's a sample code..The rest is yours..
  1. void swap(int items[], int i1, int i2)
  2. (
  3. int t = 0;
  4. t=items[i1];
  5. items[i1]=items[i2];
  6. items[i2]=t;
  7. )
  8. int main()
  9. {
  10. int n=0,m=0;
  11. const int s=4;
  12. int num[s]={4,1,2,3};
  13. int old[s]={4,1,2,3};
  14.  
  15. for(;n<s;n++)
  16. std::cout<<num[n]<<std::endl;
  17. for(n=s-1;n>0;n--)
  18. for(m=0;m<n;m++)
  19. if(num[m]>num[m+1])
  20. swap(num,m,m+1);
  21.  
  22. std::cout<<std::endl;
  23. for(n=0;n<s;n++)
  24. std::cout<<num[n]<<std::endl;
  25.  
  26. //...A few aid
  27. for x=0 to s-1
  28. for y=0 to s-1
  29. if num[x] = old[y] then
  30. the old pos=y
  31.  
  32. return 0;
  33. //done
  34. }
Last edited by cikara21; Dec 2nd, 2008 at 3:24 pm. Reason: :)
.:-cikara21-:.
Reply With Quote