Решение геодезической задачи - C#
Формулировка задачи:
Дано два значения в формате градусы:минуты:секунды. Нужно что бы результатом программы было их сложение.
Вот мой код, но он не правильно построен, просто уже нет идей
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int min_d, sec_d, min_m, sec_m, a, b, c,gr_d, gr_m;
private void label3_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
Console.WriteLine (min_d);
if (min_d > 60)
Console.WriteLine("Значение минут до 60");
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
Console.WriteLine(sec_d);
if (sec_d > 60)
Console.WriteLine("Значение секунд до 60");
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
Console.WriteLine(min_m);
if (min_m > 60)
Console.WriteLine("Значение секунд до 60");
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
Console.WriteLine(sec_m);
if (sec_m > 60)
Console.WriteLine("Значение секунд до 60");
}
private void button1_Click(object sender, EventArgs e)
{
a = min_m + min_d;
b = sec_m + sec_d;
c = gr_d + gr_m;
textBox7.Text = c.ToString();
textBox8.Text = a.ToString();
textBox9.Text = b.ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
Console.WriteLine(gr_d);
if (gr_d > 360)
Console.WriteLine("Значение градусов до 360");
}
private void textBox6_TextChanged(object sender, EventArgs e)
{
Console.WriteLine(gr_m);
if (gr_m > 360)
Console.WriteLine("Значение градусов до 360");
}
private void textBox8_TextChanged(object sender, EventArgs e)
{
}
}
}Решение задачи: «Решение геодезической задачи»
textual
Листинг программы
private void button1_Click(object sender, EventArgs e)
{
gr_d = int.Parse(textBox10.Text);
min_d = int.Parse(textBox9.Text);
sec_d = int.Parse(textBox8.Text);
gr_m = int.Parse(textBox1.Text);
min_m = int.Parse(textBox2.Text);
sec_m = int.Parse(textBox3.Text);
i = gr_d * 60 * 60 + min_d * 60 + sec_d;
f = gr_m * 60 * 60 + min_m * 60 + sec_m;
sum = i + f;
gr = sum / 3600;
min = (sum % 3600) / 60;
sec = (sum % 3600) % 60;
textBox7.Text = gr.ToString();
textBox6.Text = min.ToString();
textBox5.Text = sec.ToString();
}