I found a website already, so you don't need to make one


SUBMITTED BY: Guest

DATE: Oct. 24, 2014, 6:11 p.m.

FORMAT: C#

SIZE: 495 Bytes

HITS: 1374

  1. int i=0,j, counter=0; //variables
  2. while (x != y)
  3. {
  4. j = i+1;
  5. if (x[i] != y[i]) //You know, to skip all that if it is equal
  6. {
  7. bool eq = false;
  8. while ((!eq) && (j<n-1))// go over the string to find the correct character, stopping once you find it
  9. {
  10. //Could possibly be replicated with a for loop and a break
  11. if (x[i] == y[j])
  12. {
  13. eq = true;
  14. }
  15. }
  16. //the swap
  17. char temp = y[i];
  18. y[i] = y[j];
  19. y[j] = temp;
  20. counter++;
  21. }
  22. }
  23. return counter;

comments powered by Disqus