Guest User

Untitled

a guest
Jul 15th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1.         public static void Main(string[] args)
  2.         {
  3.             Console.WriteLine("Hello World!");
  4.            
  5.             int[] z = new int[5];
  6.             int anz, i, zs, z2, ergebnis;
  7.            
  8.             ergebnis = 0;
  9.             anz = 0;
  10.             i = 1;
  11.             zs = 0; // ??
  12.             z2 = z[i]; // ??
  13.            
  14.            
  15.  
  16.             for (i = 1; i <= 4; i++) // i++ statt i = i + 1 !!
  17.             {
  18.                 z[i] = int.Parse(Console.ReadLine());
  19.  
  20.                 anz = anz + 1;
  21.  
  22.                 while (zs > 0) // ?? Wärend des programms kommt man nie in dieser Schleife
  23.                 {
  24.                     zs = zs + (z2 % 10);
  25.                     z2 = z2 / 10;
  26.                 }
  27.  
  28.  
  29.             }
  30.            
  31.             for (i = 1; i < z.Length; i++)
  32.             {
  33.                 ergebnis += z[i];
  34.             }
  35.            
  36.             Console.WriteLine("Ziffernsumme ist "+ergebnis);
  37.             Console.ReadKey();
  38.         }
Add Comment
Please, Sign In to add comment