Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             uint Stopień;
  14.             Console.WriteLine("Podaj stopień macierzy:");
  15.             while (true)
  16.             {
  17.                 if (uint.TryParse(Console.ReadLine(), out Stopień) == true) break;
  18.                 Console.WriteLine("Błędna liczba, spróbuj ponownie");
  19.             }
  20.             double GT = 0, DT = 0.0;
  21.             for(uint Wiersz = 1; Wiersz <= Stopień; Wiersz++)
  22.             {
  23.                 for (uint Kolumna = 1; Kolumna <= Stopień; ++Kolumna)
  24.                 {
  25.                     Console.Write("Podaj element [" + Wiersz + ',' + Kolumna + "]=");
  26.                     if (Wiersz > Kolumna)
  27.                     {
  28.                         GT += double.Parse(Console.ReadLine());
  29.                     }
  30.                     else if (Wiersz < Kolumna)
  31.                     {
  32.                         DT += double.Parse(Console.ReadLine());
  33.                     }
  34.                     else
  35.                     {
  36.                         double.Parse(Console.ReadLine());
  37.                     }
  38.                    
  39.                 }
  40.                
  41.             }
  42.             Console.WriteLine("Dolny Trójkąt: " + DT);
  43.             Console.WriteLine("Górny Trójkąt: " + GT);
  44.  
  45.  
  46.  
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement