1)public void reverseString(char[] s)
{ char a;
for(int i = 0,j = s.length-1; i < j; i++,j--)
{
a = s[i];
s[i] = s[j];
s[j] = a;
}
}
2)public void reverseString(char[] s)
{ for(int i = 0,j = s.length-1; i < j; i++,j--)
{ s[i] = (char)(s[i] ^ s[j]);
s[j] = (char)(s[i] ^ s[j]);
s[i] = (char)(s[i] ^ s[j]);
}
}
添加回答
举报
0/150
提交
取消