Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. Console.Write("Bitte geben Sie die Anzahl der Zeilen der Pyramide ein: ");
  2. int zeilen = Convert.ToInt32(Console.ReadLine());
  3. string raute = "#";
  4. string stern = "*";
  5. int anzahlzeichen = -1;
  6. double hilfsvariable = 1;
  7.  
  8. while(zeilen > 0)
  9. {
  10. anzahlzeichen += 2;
  11. int x = anzahlzeichen;
  12.  
  13. while(x > 0)
  14. {
  15. if (hilfsvariable%2 == 0)
  16. {
  17. Console.Write("{0}", stern);
  18. x--;
  19. }
  20. else
  21. {
  22. Console.Write("{0}", raute);
  23. x--;
  24. }
  25. }
  26.  
  27. hilfsvariable += 1;
  28. Console.WriteLine();
  29. zeilen--;
  30. }
  31.  
  32. string str = "Hello";
  33. Console.SetCursorPosition((Console.WindowWidth - str.Length) / 2, Console.CursorTop);
  34. Console.WriteLine(str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement