walec91

Ćwiczenia #2

Nov 14th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.93 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp14
  4. {
  5.     internal class Program
  6.     {
  7.         private static void Main(string[] args)
  8.         {
  9.             #region zadanie 00
  10.             //Console.WriteLine("Podaj swoje imię");
  11.             //string imie = Console.ReadLine();
  12.             //Console.WriteLine("Witaj " + imie);
  13.  
  14.             //Console.ReadKey();
  15.             #endregion
  16.             #region zadanie 0
  17.             //int liczba;
  18.  
  19.             //Console.WriteLine("Podaj liczbę");
  20.             //liczba = int.Parse(Console.ReadLine());
  21.  
  22.             //if (liczba < 0)
  23.             //{
  24.             //    Console.WriteLine(-liczba);
  25.             //}
  26.             //else
  27.             //{
  28.             //    Console.WriteLine(liczba);
  29.             //}
  30.  
  31.             //Console.ReadLine();
  32.             #endregion
  33.             #region zadanie 7
  34.             //int a, b, c;
  35.  
  36.             //Console.WriteLine("Podaj a");
  37.             //a = Convert.ToInt32(Console.ReadLine());
  38.  
  39.             //Console.WriteLine("Podaj b");
  40.             //b = Convert.ToInt32(Console.ReadLine());
  41.  
  42.             //Console.WriteLine("Podaj c");
  43.             //c = Convert.ToInt32(Console.ReadLine());
  44.  
  45.             //if (a > b)
  46.             //{
  47.             //    if (a > c)
  48.             //    {
  49.             //        Console.WriteLine(a);
  50.             //    }
  51.             //    else
  52.             //    {
  53.             //        Console.WriteLine(c);
  54.             //    }
  55.             //}
  56.             //else
  57.             //{
  58.             //    if (b > c)
  59.             //    {
  60.             //        Console.WriteLine(b);
  61.             //    }
  62.             //    else
  63.             //    {
  64.             //        Console.WriteLine(c);
  65.             //    }
  66.             //}
  67.  
  68.             //Console.ReadKey();
  69.             #endregion
  70.             #region zadanie 2
  71.             //int liczba;
  72.  
  73.             //Console.WriteLine("Podaj liczbę");
  74.             //liczba = Convert.ToInt32(Console.ReadLine());
  75.  
  76.             //for (int i = 1; i <= liczba; i++)
  77.             //{
  78.             //    if (liczba % i == 0)
  79.             //    {
  80.             //        Console.WriteLine(i);
  81.             //    }
  82.             //}
  83.  
  84.             //Console.ReadLine();
  85.             #endregion
  86.             #region zadanie 4
  87.             //int a, b;
  88.             //int w;
  89.             //int j = 0;
  90.  
  91.             //Console.WriteLine("Podaj a");
  92.             //a = Convert.ToInt32(Console.ReadLine());
  93.             //w = a;
  94.  
  95.             //Console.WriteLine("Podaj b");
  96.             //b = Convert.ToInt32(Console.ReadLine());
  97.  
  98.             //for (j = 1; j < b; j++)
  99.             //{
  100.             //    w *= a;
  101.             //}
  102.             //Console.WriteLine(w);
  103.  
  104.             //Console.ReadLine();
  105.             #endregion
  106.             #region zadanie 1
  107.             //int n;
  108.             //int s = 0;
  109.  
  110.             //Console.WriteLine("Podaj liczbę n");
  111.             //n = Convert.ToInt32(Console.ReadLine());
  112.  
  113.             //for (int j = 0; j <= n; j++)
  114.             //{
  115.             //    s += j;
  116.             //}
  117.             //Console.WriteLine("Suma od 1 do " + n + " = " + s);
  118.  
  119.             //Console.ReadLine();
  120.             #endregion
  121.             #region zadanie 5
  122.             //int liczba;
  123.             //int suma = 0;
  124.             //int i = 0;
  125.  
  126.             //Console.WriteLine("Podaj liczbę");
  127.             //liczba = Convert.ToInt32(Console.ReadLine());
  128.  
  129.             //while (suma <= liczba)
  130.             //{
  131.             //    i++;
  132.             //    suma = suma + i;
  133.             //}
  134.             //Console.WriteLine(i);
  135.  
  136.             //Console.ReadLine();
  137.             #endregion
  138.             #region zadanie 8
  139.             //int a, b;
  140.             //int i = 0;
  141.  
  142.             //Console.WriteLine("Podaj a");
  143.             //a = Convert.ToInt32(Console.ReadLine());
  144.  
  145.             //Console.WriteLine("Podaj b");
  146.             //b = Convert.ToInt32(Console.ReadLine());
  147.  
  148.             //while (b <= a)
  149.             //{
  150.             //    a = a - b;
  151.             //    i++;
  152.             //}
  153.             //Console.WriteLine(i);
  154.  
  155.             //Console.ReadLine();
  156.             #endregion
  157.             #region zadanie 3
  158.             //double a, suma = 0;
  159.             //int i = 0, ile = 0;
  160.  
  161.             //while (i < 10)
  162.             //{
  163.             //    Console.WriteLine("Podaj liczbę");
  164.             //    a = Convert.ToInt32(Console.ReadLine());
  165.             //    i++;
  166.             //    if (a > 0)
  167.             //    {
  168.             //        suma = suma + a;
  169.             //        ile = ile + 1;
  170.             //    }
  171.             //}
  172.             //Console.WriteLine("Średnia: " + Math.Round(suma/ile, 2));
  173.  
  174.             //Console.ReadLine();
  175.             #endregion
  176.  
  177.             double moje_pi = 0;
  178.             for (int i = 0; i <= 10000; i++)
  179.             {
  180.                 moje_pi += Math.Pow(-1, i) / (2 * i + 1);
  181.             }
  182.             Console.WriteLine(moje_pi * 4);
  183.  
  184.             Console.ReadKey();
  185.         }
  186.     }
  187. }
Add Comment
Please, Sign In to add comment