Opis forum
Dodaje za pamięci kod zadania bez błędów.
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int ObwodT(int a, int b, int c)
{
return a + b + c;
}
public double PoleT(int a, int b, int c)
{
double p = (double)(a + b + c) / 2;
p = p * (p - a) * (p - b) * (p - c);
if (p > 0)
return Math.Sqrt(p);
return 0;
}
public void pobierzBokiT(ref int a, ref int b, ref int c)
{
a = Convert.ToInt32(textBox1.Text);
b = Convert.ToInt32(textBox2.Text);
c = Convert.ToInt32(textBox3.Text);
}
private void btnCalcT_Click(object sender, EventArgs e)
{
int a = 0, b = 0, c = 0, o;
double p;
pobierzBokiT(ref a, ref b, ref c);
if ((a + b > c) && (b + c > a)&& (a+c>b))
{
p = PoleT(a, b, c);
o = ObwodT(a, b, c);
textBoxPT.Text = Convert.ToString(Math.Round(p, 3));
textBox8.Text = Convert.ToString(0);
}
else
MessageBox.Show("Z Podanych odcinków nie można
zbudować trójkąta");
}
}
}
Offline