Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
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
Raw
Download
Tweet
HITS:
1374
Go to comments
Report
int
i
=
0
,
j
,
counter
=
0
;
//variables
while
(
x
!=
y
)
{
j
=
i
+
1
;
if
(
x
[
i
]
!=
y
[
i
])
//You know, to skip all that if it is equal
{
bool
eq
=
false
;
while
((
!
eq
)
&&
(
j
<
n
-
1
))
// go over the string to find the correct character, stopping once you find it
{
//Could possibly be replicated with a for loop and a break
if
(
x
[
i
]
==
y
[
j
])
{
eq
=
true
;
}
}
//the swap
char
temp
=
y
[
i
];
y
[
i
]
=
y
[
j
];
y
[
j
]
=
temp
;
counter
++
;
}
}
return
counter
;
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus