這段java代碼是自己花了很長時間寫的
import java
public class test
public static void main(String args[])
{
int size;
int count;
Scanner s=new Scanner(System
System
size=s
int array[] = new int[size];
for(int i=
{
System
array[i]=s
}
System
for(int j=
{
System
}
System
System
count=s
int[] temp=new int[size];
for(int i=
{
if(i<count)
{
temp[i]=
}
else
{
temp[i]=
}
}
System
for(int i=
{
System
}
System
boolean flag=false;
int key=
do //循環進行轉置操作
{
int position=
int numbers=
int q=
int[] result=new int[count];
System
for(int i=
{
if(temp[i]==
{
result[q]=array[i];
System
q++;
}
}
for (int i =
{
if (temp[i] ==
{
temp[i] =
temp[i +
position = i; //第一次循環掃描後
break; //跳出if循環
}
}
for (int i =
{
if (temp[i] ==
numbers++;
}
for (int i =
{
if (i < numbers)
temp[i] =
else
temp[i] =
}
System
System
for(int i=
{
System
}
flag=false;
for (int i = size
{
if (temp[i] ==
flag = true; //如果從第size
}
key++;
}while(flag);
int p=
int[] array
System
for(int i=
{
if(temp[i]==
{
array
System
p++;
}
}
System
System
}
}
這個程序采用了一個臨時的temp數組
通過上面簡短的介紹
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26442.html