Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 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 übung
  8. {
  9.     class Program
  10.     {
  11.         public static int m1(int n)
  12.         {
  13.             int z = 0;
  14.             int schritte = 0;
  15.             while (n > 1)
  16.             {
  17.                 n /= 2;
  18.                 z++;
  19.                 schritte++;
  20.             }
  21.             Console.Write("Steps: " + schritte + " - ");
  22.             return z;
  23.         }
  24.  
  25.         public static int m2(int n)
  26.         {
  27.             int i = 1;
  28.             int b = 1;
  29.             while (i < n)
  30.             {
  31.                 b = b + 2 * i + 1;
  32.                 i++;
  33.             }
  34.             return b;
  35.         }
  36.  
  37.         public static int m3(int n)
  38.         {
  39.             int t = 1, z = 0;
  40.             while (n > 0)
  41.             {
  42.                 n = n - t;
  43.                 t = t + 2;
  44.                 z++;
  45.             }
  46.             return z;
  47.         }
  48.         public static int m4(int n)
  49.         {
  50.             return m3(m1(n));
  51.         }
  52.         public static int m5(int n)
  53.         {
  54.             return m2(m3(n));
  55.         }
  56.  
  57.         public static int m6(int n)
  58.         {
  59.             return m3(m2(n));
  60.         }
  61.         public static int m7(int n)
  62.         {
  63.             int z = 0;
  64.             for (int i = 1; i <= m3(n); i++)
  65.                 z = z + m3(n);
  66.             return z;
  67.         }
  68.         public static int m8(int n)
  69.         {
  70.             int z = 0;
  71.             int y = m3(n);
  72.             for (int i = 1; i <= y; i++)
  73.                 z = z + m3(n);
  74.             return z;
  75.         }
  76.         public static int m9(int n)
  77.         {
  78.             return m3(n) + m1(n);
  79.         }
  80.         public static int m10(int n)
  81.         {
  82.             return m2(m2(n));
  83.         }
  84.  
  85.         static void werteTabelle(Func<int, int> mx, int min, int max)
  86.         {
  87.             for (int i = min; i <= max; i++)
  88.             {
  89.                 Console.WriteLine("n = " + i + " - ret = " + mx(i));
  90.             }
  91.         }
  92.  
  93.         static void Main(string[] args)
  94.         {
  95.             int n = 200;
  96.             werteTabelle(m1, 1, 60);
  97.             Console.ReadKey();
  98.         }
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement