Advertisement
batox

WSB [#03] LAB - podstawy

Nov 14th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.59 KB | None | 0 0
  1. using System;
  2.  
  3. namespace INFLAB01
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args) // ctrl K ctrl D
  8.         {
  9.             #region "Przyklad 1";
  10.             //Console.WriteLine("Podaj swoje imię");
  11.             //string imie = Console.ReadLine();
  12.             //Console.WriteLine("Witaj: " + imie);
  13.  
  14.             //Console.ReadKey();
  15.             #endregion
  16.             #region "Przyklad2";
  17.             //Int32 liczba;
  18.             //Console.WriteLine("Podaj liczbe 123");
  19.             //liczba = Convert.ToInt32(Console.ReadLine());
  20.             //liczba = System.Int32.Parse(Console.ReadLine());
  21.             ////liczba = Math.Abs(liczba);
  22.             //Console.WriteLine(Math.Abs(liczba));
  23.  
  24.             //if (liczba<0)
  25.             //{
  26.             //    liczba = -liczba;
  27.             //    Console.WriteLine(liczba);
  28.             ////}
  29.             ////else
  30.             ////{
  31.             ////    Console.WriteLine(liczba);
  32.             ////}
  33.             #endregion
  34.             #region "Przyklad3";
  35.             //int a, b, c;
  36.             //Console.WriteLine("podaj a b i c");
  37.             //a = Convert.ToInt32(Console.ReadLine());
  38.             //b = Convert.ToInt32(Console.ReadLine());
  39.             //c = Convert.ToInt32(Console.ReadLine());
  40.  
  41.             //if (a > b)
  42.             //{
  43.             //    if (a > c)
  44.             //    {
  45.             //        Console.WriteLine("A jest najwieksze" + a);
  46.             //    }
  47.             //    else
  48.             //    {
  49.             //        Console.WriteLine("C jest najwieksze" + c);
  50.             //    }
  51.             //}
  52.             //else
  53.             //{
  54.             //    if (b > c)
  55.             //    {
  56.             //        Console.WriteLine("B jest najwieksze: " + b);
  57.             //    }
  58.             //    else
  59.             //    {
  60.             //        Console.WriteLine("C jest najwieksze: " + c);
  61.             //    }
  62.  
  63.             //}
  64.             #endregion
  65.             #region "Przyklad 4";
  66.             //int i;
  67.             //for(i=1; i <=3; i=i+2)
  68.             //{
  69.             //    Console.WriteLine(i);
  70.             //}
  71.             //Console.ReadKey();
  72.             #endregion
  73.  
  74.             #region "Zadanie 1";
  75.             //Użytkownik podaje liczbę naturalną. Program wyświetla wszystkie dzielniki tej liczby.
  76.  
  77.             //int liczba;
  78.             //Console.WriteLine("Podaj liczbe");
  79.             //liczba = Convert.ToInt32(Console.ReadLine());
  80.             //for (int i = 1; i <= liczba; i++)
  81.             //{
  82.             //    if (liczba % i == 0)
  83.             //    {
  84.             //        Console.WriteLine(i);
  85.             //    }
  86.             //}
  87.             //Console.ReadKey();
  88.             #endregion
  89.  
  90.             #region "Zadanie 2";
  91.             //Użytkownik podaje dwie liczby a oraz b. Program oblicza potęga a do b.
  92.  
  93.             //int liczbaA;
  94.             //int liczbaB;
  95.             //int wynik;
  96.             //Console.WriteLine("Podaj liczbe A - podstawe ");
  97.             //liczbaA = Convert.ToInt32(Console.ReadLine());
  98.             //Console.WriteLine("Podaj liczbe B - wykladnik");
  99.             //liczbaB = Convert.ToInt32(Console.ReadLine());
  100.  
  101.             //wynik = liczbaA;
  102.  
  103.             //for (int i = 1; i<liczbaB; i++)
  104.             //{
  105.             //    wynik = wynik * liczbaA;
  106.             //}
  107.  
  108.             //Console.WriteLine(wynik);
  109.             //Console.ReadKey();
  110.             #endregion
  111.  
  112.             #region "Zadanie 3";
  113.             //Użytkownik podaje liczbę naturalną n. Program oblicza, ile wynosi suma kolejnych liczb naturalnych od 1 do n..
  114.             //int liczbaA;
  115.             //int i;
  116.             //int wynik=0;
  117.             //Console.WriteLine("Podaj liczbe");
  118.             //liczbaA = Convert.ToInt32(Console.ReadLine());
  119.             //for (i = 1; i <= liczbaA; i++)
  120.             //{
  121.             //    wynik +=  i;
  122.             //}
  123.  
  124.             //Console.WriteLine(wynik);
  125.             //Console.ReadKey();
  126.             #endregion
  127.  
  128.             #region "Zadanie 4";
  129.             //Użytkownik podaje liczbę naturalną. Program oblicza, ile kolejnych liczb naturalnych należy dodać, aby ich suma przekroczyła zadaną liczbę.
  130.  
  131.             //int liczbaA;
  132.             //int i=0;
  133.             //int suma=0;
  134.             //Console.WriteLine("Podaj liczbe");
  135.             //liczbaA = Convert.ToInt32(Console.ReadLine());
  136.             //while(suma<=liczbaA)
  137.             //{
  138.  
  139.             //    i++;
  140.             //    Console.WriteLine("Twoje i po ++: " + i);
  141.             //    suma = suma + i;
  142.             //    Console.WriteLine("suma to: " + suma);
  143.             //}
  144.  
  145.             //Console.WriteLine("Trzeba dodac "+ i + " liczb");
  146.             //Console.ReadKey();
  147.             #endregion
  148.  
  149.             #region "Zadanie 5";
  150.             //Użytkownik podaje liczby naturalne a oraz b. Program wyświetla część całkowitą z dzielenia a / b..int liczba
  151.  
  152.             //int a;
  153.             //int b;
  154.             //int i = 0;
  155.             //Console.WriteLine("Podaj liczbe a i b");
  156.             //a = Convert.ToInt32(Console.ReadLine());
  157.             //b = Convert.ToInt32(Console.ReadLine());
  158.             //while(a>=b)
  159.             //    {
  160.             //    a = a - b;
  161.             //    i++;
  162.             //    Console.WriteLine("A to  :" + a);
  163.             //    Console.WriteLine("I to  :" + i);
  164.  
  165.             //}
  166.             //Console.WriteLine(i);
  167.  
  168.  
  169.             #endregion
  170.  
  171.             #region "Zadanie 6";
  172.             //Użytkownik podaje 10 liczb. Program oblicza średnią arytmetyczną liczb dodatnich;
  173.  
  174.             //int a=0;
  175.             //int i = 0;
  176.             //double wynik=0;
  177.  
  178.             //while(i<10)
  179.             //{
  180.             //    Console.WriteLine("Podaj liczbe a");
  181.             //    a = Convert.ToInt32(Console.ReadLine());
  182.             //    wynik = a + wynik;
  183.             //      i++;
  184.             //    //Console.WriteLine("I to: " + i);
  185.             //    //Console.WriteLine("A to: " + a);
  186.             //    //Console.WriteLine("W to: " + wynik);
  187.             //}
  188.  
  189.             // //double wynikDouble = Convert.ToDouble(wynik);
  190.  
  191.             //Console.WriteLine("Wynik to: " + (wynik / 10));
  192.             //Console.ReadKey();
  193.  
  194.             #endregion
  195.  
  196.             #region "Zadanie 7";
  197.             //Liczba Pi 10000;
  198.             //double i = 0;
  199.             //double WynikPi=0;
  200.  
  201.             //for (i=0;i<=10000;i++)
  202.             //{
  203.             //    WynikPi += Math.Pow(-1, i) / (2 * i + 1);
  204.                
  205.      
  206.             //}
  207.             //Console.WriteLine(WynikPi*4);
  208.  
  209.             //Console.ReadKey();
  210.  
  211.             #endregion
  212.         }
  213.     }
  214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement