Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace NumbersOfTriangles
- {
- class NumbersOfTriangles
- {
- class Triangles
- {
- static int a, b, c, d;
- int TriangleSides = 3;
- int[] Values = { a, b, c, d };
- public Triangles()
- {
- Console.WriteLine("Podaj długość boku a: ");
- a = Int32.Parse(Console.ReadLine());
- Console.WriteLine("Podaj długość boku b: ");
- b = Int32.Parse(Console.ReadLine());
- Console.WriteLine("Podaj długość boku c: ");
- c = Int32.Parse(Console.ReadLine());
- Console.WriteLine("Podaj długość boku d: ");
- d = Int32.Parse(Console.ReadLine());
- }
- public int AllTriangles()
- {
- int n = Values.Length;
- int k = TriangleSides;
- int nk = n - k;
- int factorialN= 1;
- int factorialK= 1;
- int factorialNK=1;
- int FactorialN()
- {
- for (int i = 1; i <= n; i++)
- {
- factorialN *= i;
- }
- return factorialN;
- }
- int FactorialK()
- {
- for (int i = 1; i <= k; i++)
- {
- factorialK *= i;
- }
- return factorialK;
- }
- int FactorialNK()
- {
- for (int i = 1; i <= nk; i++)
- {
- factorialNK *= i;
- }
- return factorialNK;
- }
- int FN = FactorialN();
- int FK = FactorialK();
- int FnK = FactorialNK();
- int NumberOfTriangles = FN / FK * FnK;
- return NumberOfTriangles;
- }
- public int[,] DivisionOfTriangles()
- {
- int[,] Triangles = new int[AllTriangles(), TriangleSides];
- int x = 0;
- for (int row = 0; row < Triangles.GetLength(0); row++)
- {
- for (int column = 0; column < Triangles.GetLength(1); column++)
- {
- if (column + x == 4)
- {
- x = -2;
- }
- if (row == 3 && column == 0)
- {
- x = 3;
- }
- else if (row == 3 && column != 0)
- {
- x = -1;
- }
- Triangles[row,column] = Values[column + x];
- }
- x++;
- }
- return Triangles; //jak zwrócić wypełnioną tablicę?
- }
- static void Main(string[] args)
- {
- Triangles Triangles = new Triangles();
- Console.WriteLine(Triangles.DivisionOfTriangles()); //podupione łubudu
- Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment