W1thr

Функции-2

Feb 20th, 2021 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 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 Homework2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             char fill = '#';
  14.             int fillPercent = 40;
  15.             int maxValue = 10;
  16.             int positionY = 1;
  17.             DrawBar(fillPercent,maxValue,fill,positionY);
  18.         }
  19.  
  20.         static void DrawBar(int fillPercent, int maxValue, char fill, int positionY)
  21.         {
  22.             int value = fillPercent * maxValue / 100 ;
  23.  
  24.             Console.CursorVisible = false;
  25.             Console.SetCursorPosition(0, positionY);
  26.  
  27.             Console.Write('[');
  28.             for (int i = 0; i < value; i++)
  29.             {
  30.                 Console.Write(fill);
  31.             }
  32.             for (int i = value; i < maxValue; i++)
  33.             {
  34.                 Console.Write('_');
  35.             }
  36.             Console.Write(']');
  37.         }
  38.     }
  39. }
  40.  
Add Comment
Please, Sign In to add comment