发布网友 发布时间:2022-04-20 16:00
共1个回答
热心网友 时间:2023-07-06 11:42
告诉你算法
int num=0;
从es的后面开始,如果当前es的元素在ls中出现,ls中的当前元素和es[num++]交换,循环完es,结果就出来了
public class Test
{
public static void main(String[] args)
{
String stemp;
String[] ls = {"A","B","C","V","G","H","K","M","N","S","P","U","V","W","S"};
String [] es = {"B","K","S","U","N"};
int num=0;
for(int i=es.length-1;i>=0;i--)
for(int j=0;j<ls.length,j++)
{
if(ls[j].equals(es[i]))
{
stemp=ls[num];
ls[num++]=ls[j];
ls[j]=temp;
}
}
}
}