Advertisement
Guest User

ggt

a guest
Oct 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 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 ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static public int[] list = new int [10];
  12.         static public String read;
  13.         static public int x = 0;
  14.         static public int g = 0;
  15.         static public int a;
  16.         static public int b;
  17.         static public int z = 1;
  18.         static public int lenght;
  19.  
  20.         static void Main(string[] args)
  21.         {
  22.            
  23.             while (read != "exit")
  24.             {
  25.                 if (g == 10)
  26.                 {
  27.                     lenght = list.Length + 10;                
  28.                     int[] temp = new int[list.Length];
  29.                     Array.Copy(list, temp, 10);
  30.                     list = new int[lenght];
  31.                     Array.Copy(temp, list, 10);
  32.                 }
  33.  
  34.                 A:
  35.                 read = Console.ReadLine();
  36.                 if (read != "exit")
  37.                 {
  38.                     list[x] = Int32.Parse(read);
  39.                     if (list[x] == 0)
  40.                     {
  41.                         Console.WriteLine(" Die Zahl muss größer als 0 sein");
  42.                         Console.ReadKey();
  43.                         Console.Clear();
  44.                         goto A;
  45.                     }
  46.                 }
  47.                 g++;
  48.                 x++;
  49.             }
  50.  
  51.             foreach (int i in list)
  52.             {
  53.                 System.Console.Write("{0} ", i);
  54.             }
  55.  
  56.             lenght = list.Length;
  57.             a = list[0];
  58.             while(lenght != 1)
  59.             {
  60.                 b = list[z];
  61.                 while (b != 0)
  62.                 {
  63.                     if (a > b)
  64.                     {
  65.                      a = a- b;
  66.                     }
  67.                 else
  68.                 {
  69.                     b = b - a;
  70.                 }
  71.                 }
  72.                 z++;
  73.                 lenght = lenght - 1;
  74.             }
  75.             Console.WriteLine("");
  76.             Console.WriteLine("ggT: " + a);
  77.             Console.ReadKey();
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement