Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 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 Czapla
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n;
  14.             double xStart, xKoniec, deltaX;
  15.  
  16.             List<double> w = new List<double>();
  17.  
  18.             Console.Write("n = ");
  19.             n = int.Parse(Console.ReadLine());
  20.  
  21.             Console.Write("x start = ");
  22.             xStart = double.Parse(Console.ReadLine());
  23.  
  24.             Console.Write("x koniec = ");
  25.             xKoniec = double.Parse(Console.ReadLine());
  26.  
  27.  
  28.             deltaX = (xKoniec - xStart) / (n - 1);
  29.  
  30.             for (int i = 0; i < n ; i++)
  31.             {
  32.                 w.Add(xStart + (deltaX * i)) ;
  33.             }
  34.  
  35.             Console.WriteLine();
  36.             Console.Write("<W> = [ ");
  37.             foreach (var x in w)
  38.             {
  39.                 Console.Write(x);
  40.                 Console.Write(" ");
  41.             }
  42.             Console.Write(" ]");
  43.  
  44.             double[,] macierz = new double[n,n];
  45.             for(int i = 0; i < n; i++)
  46.             {
  47.                 for(int j = 0; j < n; j++)
  48.                 {
  49.                     macierz[i, j] = (i + 1) * w[j];
  50.                 }
  51.             }
  52.             Console.WriteLine();
  53.             Console.WriteLine("Wyswietl macierz");
  54.             Console.Write("[W] = ");
  55.             for (int i = 0; i < n; i++)
  56.             {
  57.                 Console.Write("[ ");
  58.                 for (int j = 0; j < n; j++)
  59.                 {
  60.                     Console.Write(macierz[i, j]);
  61.                     Console.Write(" ");
  62.                 }
  63.                 Console.Write(" ]");
  64.                 Console.WriteLine();
  65.             }
  66.  
  67.  
  68.             Console.ReadKey();
  69.  
  70.  
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement