java在线解答
发布网友
发布时间:2022-04-25 09:02
我来回答
共1个回答
热心网友
时间:2023-11-11 13:49
看图
追答package com.domain;
public class A {
public static void main(String[] args) {
String s = "ABCDE";//自己换键盘录入
arr(s);
}
public static void arr(String s){
//字符转字符串数组
char[] array = s.toCharArray();
for(int x=0; x<array.length ;x++){
if(x != array.length/2){
char a = array[x];
array[x] = array[array.length-1-x];
array[array.length-1-x] = a;
}else{
break;
}
}
//遍历数组
for(int x=0; x<array.length ;x++){
System.out.print(array[x]);
}
}
}
热心网友
时间:2023-11-11 13:49
看图
追答package com.domain;
public class A {
public static void main(String[] args) {
String s = "ABCDE";//自己换键盘录入
arr(s);
}
public static void arr(String s){
//字符转字符串数组
char[] array = s.toCharArray();
for(int x=0; x<array.length ;x++){
if(x != array.length/2){
char a = array[x];
array[x] = array[array.length-1-x];
array[array.length-1-x] = a;
}else{
break;
}
}
//遍历数组
for(int x=0; x<array.length ;x++){
System.out.print(array[x]);
}
}
}
热心网友
时间:2023-11-11 13:49
看图
追答package com.domain;
public class A {
public static void main(String[] args) {
String s = "ABCDE";//自己换键盘录入
arr(s);
}
public static void arr(String s){
//字符转字符串数组
char[] array = s.toCharArray();
for(int x=0; x<array.length ;x++){
if(x != array.length/2){
char a = array[x];
array[x] = array[array.length-1-x];
array[array.length-1-x] = a;
}else{
break;
}
}
//遍历数组
for(int x=0; x<array.length ;x++){
System.out.print(array[x]);
}
}
}
热心网友
时间:2023-11-11 13:49
看图
追答package com.domain;
public class A {
public static void main(String[] args) {
String s = "ABCDE";//自己换键盘录入
arr(s);
}
public static void arr(String s){
//字符转字符串数组
char[] array = s.toCharArray();
for(int x=0; x<array.length ;x++){
if(x != array.length/2){
char a = array[x];
array[x] = array[array.length-1-x];
array[array.length-1-x] = a;
}else{
break;
}
}
//遍历数组
for(int x=0; x<array.length ;x++){
System.out.print(array[x]);
}
}
}
热心网友
时间:2023-11-11 13:50
看图
追答package com.domain;
public class A {
public static void main(String[] args) {
String s = "ABCDE";//自己换键盘录入
arr(s);
}
public static void arr(String s){
//字符转字符串数组
char[] array = s.toCharArray();
for(int x=0; x<array.length ;x++){
if(x != array.length/2){
char a = array[x];
array[x] = array[array.length-1-x];
array[array.length-1-x] = a;
}else{
break;
}
}
//遍历数组
for(int x=0; x<array.length ;x++){
System.out.print(array[x]);
}
}
}