-2
我想寫一個sky-l-i-n-e的程序。起初,我給了x,然後是高度,然後是寬度。例如(1,2,3)將存儲在 sky[0,0,0]
和x = 1,height = 2,width = 3。 你的建議是什麼?我知道其他人寫了這個,但我想有另一種方式。用戶將決定該圖有多少點。演員會給數字,然後我會按x排序數據,因爲x是重要的參數。如何排序天空數組並從一個按鈕初始化數組?
排序部分不起作用。問題是什麼?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static int [,]sortedsky=new int[1,1];
public static int row;
public static int x = 0;
public static int [,]sky=new int[1,1];
public static int charrsize(int i, int j)
{
int [,]a=new int [i,j];
sky = a;
sortedsky =sky;
return 1;
}
public static int sort(int [,]a,int i)
{
int y=0;
sky = a;
int min=0;
int tx=0;
int th=0;
int tx2 = 0;
int low=0;
for (int f = 0; f<i; f++)
{
low++;
tx= sky[low,0];
th= sky[low,1];
tx2=sky[low,2];
sky[low,0]=sky[min,0];
sky[low,1]=sky[min,1];
sky[low,2]=sky[min,2];
sky[min,0]=tx;
sky[min,1]=th;
sky[min,2]=tx2;
min = f;
for (y = 0; y < i-1; y++)
if (sky[y+1, 0] < sky[min, 0])
min = y+!;
}
return 1;
}
private void button1_Click(object sender, EventArgs e)
{
row =int.Parse (textBox4 .Text);
charrsize(row, 3);
}
private void textBox3_TextChanged(object sender, EventArgs e)
{ }
public void textBox4_TextChanged(object sender, EventArgs e)
{ }
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = x.ToString();
if (x<row)
{
//here is my problem:
sky[x, 0] = int.Parse(txtx.Text);
sky[x, 1] = int.Parse(txth.Text);
sky[x, 2] = int.Parse(txtx2.Text);
}
else
{
MessageBox.Show("enough! it was the last");
sort(sky, row);
}
x++;
}
private void Form1_Load(object sender, EventArgs e)
{ }
private void label2_Click(object sender, EventArgs e)
{ }
}
我們的日常WTF ..這將是偉大的,如果你會第一次嘗試解釋你正在嘗試做什麼。 – codymanix
不要生氣先生我會表示抱歉。 –
大聲笑 - 「不要生氣先生」 - 讓我想起Bon Qui Qui! –