Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp3
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.     }
  20. }
  21. public struct Triangle
  22. {
  23.     public int h;
  24.     public int b;
  25.  
  26.     public Triangle(int h, int b)
  27.     {
  28.         this.h = h;
  29.         this.b = b;
  30.     }
  31.     public int Surface()
  32.     {
  33.         return h * b / 2;
  34.  
  35.     }
  36.  
  37. }
  38.  
  39. private static void Main(string[] args)
  40. {
  41.     Triangle[] triangles = new Triangle[3];
  42.     for (int i = 0; i < triangles.Length; i++)
  43.     {
  44.         Console.Write("Triangle"+(i+1)+"b:");
  45.         triangles[i].b = int.Parse(Console.ReadLine());
  46.         Console.Write("Triangle" + (i + 1) + "h:");
  47.         triangles[i].h = int.Parse(Console.ReadLine());
  48.     }
  49.     for (int i = 0; i < triangles.Length; i++)
  50.     {
  51.         Console.WriteLine("triangle " + (1 + i) + "surface area:" + triangles[i].Surface()); ;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement