Buat Soal Nomor 2 kurang lebih sama aja kaya gini oke.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Program_GUI
{
public partial class frm_arr1d : Form
{
int[,] data = new int[7, 7];
int i = 0;
int j = 0;
public frm_arr1d()
{
InitializeComponent();
}
private void btn_tampil_Click(object sender, EventArgs e)
{
for (int i = 0; i < 7; i++)
{
string temp = "";
for (int j = 0; j < 7; j++)
{
temp += data[i, j]+ "\t";
}
lb_data.Items.Add(temp);
}
}
private void btn_input_Click(object sender, EventArgs e)
{
data[i, j] = int.Parse(txt_input.Text);
txt_input.Clear();
txt_input.Focus();
j++;
if (j == 7)
{
j = 0;
i++;
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Program_GUI
{
public partial class frm_arr1d : Form
{
int[,] data = new int[7, 7];
int i = 0;
int j = 0;
public frm_arr1d()
{
InitializeComponent();
}
private void btn_tampil_Click(object sender, EventArgs e)
{
for (int i = 0; i < 7; i++)
{
string temp = "";
for (int j = 0; j < 7; j++)
{
temp += data[i, j]+ "\t";
}
lb_data.Items.Add(temp);
}
}
private void btn_input_Click(object sender, EventArgs e)
{
data[i, j] = int.Parse(txt_input.Text);
txt_input.Clear();
txt_input.Focus();
j++;
if (j == 7)
{
j = 0;
i++;
}
}
}
}
Tidak ada komentar:
Posting Komentar