Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 WindowsFormsApp3
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
- }
- public struct Triangle
- {
- public int h;
- public int b;
- public Triangle(int h, int b)
- {
- this.h = h;
- this.b = b;
- }
- public int Surface()
- {
- return h * b / 2;
- }
- }
- private static void Main(string[] args)
- {
- Triangle[] triangles = new Triangle[3];
- for (int i = 0; i < triangles.Length; i++)
- {
- Console.Write("Triangle"+(i+1)+"b:");
- triangles[i].b = int.Parse(Console.ReadLine());
- Console.Write("Triangle" + (i + 1) + "h:");
- triangles[i].h = int.Parse(Console.ReadLine());
- }
- for (int i = 0; i < triangles.Length; i++)
- {
- Console.WriteLine("triangle " + (1 + i) + "surface area:" + triangles[i].Surface()); ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement