Объяснение:
h,w = int(input().split())
c,p = int(input().split())
s = []
roadm = []
parks = []
cp = []
for i in range(1, h+1):
for j in range(1, w+1):
s.append([i,j])
for k in s:
if k[0]==1 or k[1]==1:
roadm.append(s.pop(k))
for t in s:
if t[0] == 2 or t[1] == 2:
cp.append(s.pop(t))
for y in s:
if y[0] == (f[0]+1 for f in cp) and y[1] == (f[1]+1 for f in cp) and y[0] == (f[0]-1 for f in cp) and y[1] == (f[1]-1 for f in cp):
parks.append(s.pop(y))
a = []
b = []
for o in s:
a.append(o[0])
b.append(o[1])
print(min(a))
print(min(b))
C# самый простой вариант. Не нравится - совершенствуйте
на форму label1, textBox1, textBox2, textBox3, button1, button2, button3, this.button4, this.button5, this.button6
в Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
public Form1()
InitializeComponent();
}
double a, b, result;
private void button1_Click(object sender, EventArgs e)
a = Convert.ToDouble(textBox1.Text);
b = Convert.ToDouble(textBox2.Text);
label1.Text = "Сумма";
result = a + b;
textBox3.Text = Convert.ToString(result);
private void button2_Click(object sender, EventArgs e)
label1.Text = "Разность";
result = a - b;
private void button3_Click(object sender, EventArgs e)
label1.Text = "Произведение";
textBox3.Text = Convert.ToString(Convert.ToDouble(textBox1.Text) * Convert.ToDouble(textBox2.Text));
private void button4_Click(object sender, EventArgs e)
label1.Text = "Частное";
result = a / b;
private void button5_Click(object sender, EventArgs e)
textBox3.Text = Convert.ToString(Convert.ToDouble(textBox1.Text) * Convert.ToDouble(textBox1.Text));
private void button6_Click(object sender, EventArgs e)
textBox3.Text = Convert.ToString(Math.Sqrt(Convert.ToDouble(textBox1.Text)));
Объяснение:
h,w = int(input().split())
c,p = int(input().split())
s = []
roadm = []
parks = []
cp = []
for i in range(1, h+1):
for j in range(1, w+1):
s.append([i,j])
for k in s:
if k[0]==1 or k[1]==1:
roadm.append(s.pop(k))
for t in s:
if t[0] == 2 or t[1] == 2:
cp.append(s.pop(t))
for y in s:
if y[0] == (f[0]+1 for f in cp) and y[1] == (f[1]+1 for f in cp) and y[0] == (f[0]-1 for f in cp) and y[1] == (f[1]-1 for f in cp):
parks.append(s.pop(y))
a = []
b = []
for o in s:
a.append(o[0])
b.append(o[1])
print(min(a))
print(min(b))
C# самый простой вариант. Не нравится - совершенствуйте
на форму label1, textBox1, textBox2, textBox3, button1, button2, button3, this.button4, this.button5, this.button6
в Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double a, b, result;
private void button1_Click(object sender, EventArgs e)
{
a = Convert.ToDouble(textBox1.Text);
b = Convert.ToDouble(textBox2.Text);
label1.Text = "Сумма";
result = a + b;
textBox3.Text = Convert.ToString(result);
}
private void button2_Click(object sender, EventArgs e)
{
a = Convert.ToDouble(textBox1.Text);
b = Convert.ToDouble(textBox2.Text);
label1.Text = "Разность";
result = a - b;
textBox3.Text = Convert.ToString(result);
}
private void button3_Click(object sender, EventArgs e)
{
label1.Text = "Произведение";
textBox3.Text = Convert.ToString(Convert.ToDouble(textBox1.Text) * Convert.ToDouble(textBox2.Text));
}
private void button4_Click(object sender, EventArgs e)
{
a = Convert.ToDouble(textBox1.Text);
b = Convert.ToDouble(textBox2.Text);
label1.Text = "Частное";
result = a / b;
textBox3.Text = Convert.ToString(result);
}
private void button5_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString(Convert.ToDouble(textBox1.Text) * Convert.ToDouble(textBox1.Text));
}
private void button6_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString(Math.Sqrt(Convert.ToDouble(textBox1.Text)));
}
}
}