walec91

Ćwiczenia #7

Jan 16th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.81 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp23
  4. {
  5.     #region nowa klasa
  6.     //static class Moja_klasa
  7.     //{
  8.     //    static public int sumka(int k)
  9.     //    {
  10.     //        int i, s = 0;
  11.     //        for (i = 1; i <= k; i++)
  12.     //        {
  13.     //            s = s + i;
  14.     //        }
  15.     //        return s;
  16.     //    }
  17.     //    static public int sumka2(int j)
  18.     //    {
  19.     //        if (j == 1)
  20.     //        {
  21.     //            return 1;
  22.     //        }
  23.     //        else
  24.     //        {
  25.     //            return sumka2(j - 1) + j;
  26.     //        }
  27.     //    }
  28.     //    static public double potega(int a, int b)
  29.     //    {
  30.     //        if (b == 1)
  31.     //        {
  32.     //            return a;
  33.     //        }
  34.     //        else
  35.     //        {
  36.     //            return potega(a, b - 1) * a;
  37.     //        }
  38.     //    }
  39.     //    static public int silnia(int n)
  40.     //    {
  41.     //        if (n==1)
  42.     //        {
  43.     //            return 1;
  44.     //        }
  45.     //        else
  46.     //        {
  47.     //            return silnia(n - 1) * n;
  48.     //        }
  49.     //    }
  50.     //}
  51.     #endregion
  52.     #region ciąg fibonacciego.1
  53.     //class Funkcje
  54.     //{
  55.     //    public long ile = 0;
  56.     //    public long fibek (int n)
  57.     //    {
  58.     //        ile++;
  59.  
  60.     //        if (( n== 1) || (n == 2))
  61.     //        {
  62.     //            return 1;
  63.     //        }
  64.     //        else
  65.     //        {
  66.     //            return fibek(n - 1) + fibek(n - 2);
  67.     //        }
  68.     //    }
  69.     //}
  70.     #endregion
  71.     class Program
  72.     {
  73.         #region referencje
  74.         //static int funkcja1(ref int n)
  75.         //{
  76.         //    return ++n;
  77.         //}
  78.         #endregion
  79.         #region zd.referencje
  80.         //static void funkcja_zamien(ref int a, ref int b)
  81.         //{
  82.         //    int tmp;
  83.         //    tmp = a;
  84.         //    a = b;
  85.         //    b = tmp;
  86.         //}
  87.         #endregion
  88.         #region metody przeciążone
  89.         //public static double pole(int r)
  90.         //{
  91.         //    return Math.PI * Math.Pow(r, 2);
  92.         //}
  93.         //public static int pole(int a, int b)
  94.         //{
  95.         //    return a*b;
  96.         //}
  97.         #endregion
  98.         static void Main(string[] args)
  99.         {
  100.             #region nowa klasa.1  
  101.             //int n = 3;
  102.             //Console.WriteLine("sumka = " + Moja_klasa.sumka(n));
  103.             //Console.WriteLine("sumka2 = " + Moja_klasa.sumka2(3));
  104.             //Console.WriteLine("potęga = " + Moja_klasa.potega(2, 10));
  105.             //Console.WriteLine("silnia = " + Moja_klasa.silnia(8));
  106.             //Console.ReadLine();
  107.             #endregion
  108.             #region ciąg fibonacciego.1
  109.             //         Funkcje fun = new Funkcje();
  110.             //         int n = 45;
  111.  
  112.             //         for (int i = 1; i <= n; i++)
  113.             //{
  114.             //             fun.ile = 0;
  115.             //             Console.WriteLine("n = "+ i + "\t fibek = " + fun.fibek(i) + "\t ile razy = " + fun.ile);
  116.             //}
  117.             //         Console.ReadLine();
  118.             #endregion
  119.             #region referencje.1
  120.             //int x = 5;
  121.             //int y;
  122.             //y = funkcja1(ref x);
  123.             //Console.WriteLine(x);
  124.             //Console.ReadLine();
  125.             #endregion
  126.             #region zd.referencje.1
  127.             //int x = 2, y = 3;
  128.             //funkcja_zamien(ref x, ref y);
  129.             //Console.WriteLine("x = " + x);
  130.             //Console.WriteLine("y = " + y);
  131.             //Console.ReadLine();
  132.             #endregion
  133.             #region metody przeciążone.1
  134.             //Console.WriteLine("Pole prostokąta wynosi: " + Program.pole(2, 3));
  135.             //Console.WriteLine("Pole koła wynosi: " + Program.pole(1));
  136.             //Console.ReadLine();
  137.             #endregion
  138.         }
  139.     }
  140. }
Add Comment
Please, Sign In to add comment