Új hozzászólás Aktív témák
-
nmate91
tag
using System;
using System.Threading;
namespace ConsoleApp1
{
class Program
{
static int Increase(int count)
{
do
{
while (!Console.KeyAvailable)
{
Console.WriteLine($"count: {count++}");
Thread.Sleep(25);
}
} while (Console.ReadKey(true).Key != ConsoleKey.Spacebar);
return count;
}
static int Decrease(int count)
{
do
{
while (!Console.KeyAvailable)
{
Console.WriteLine($"count: {count--}");
Thread.Sleep(25);
}
} while (Console.ReadKey(true).Key != ConsoleKey.Spacebar);
return count;
}
static void Main(string[] args)
{
Console.WriteLine("Press Space to change, and ESC to stop");
do
{
int count = 0;
count = Increase(count);
count = Decrease(count);
} while (Console.ReadKey(true).Key != ConsoleKey.Escape);
}
}
}Hasonlo, decrease utan megall, ujra spacet nyomva indul, nullarol. Ha nem nullarol kell, csak ki kell tenni eggyel kijjebb a count deklaralast. Ha kell az 1000 hatarnak, csak a do while-nal kondiciokent kikotod.
Új hozzászólás Aktív témák
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Számlás!Steam,EA,Epic és egyébb játékok Pc-re vagy XBox!
- Shining3D EinScan Pro 2X 3D szkenner
- Samsung Galaxy S20 Ultra / 12/128GB / Kártyafüggetlen / 12Hó Garancia
- Dell Latitude 5420 14" Touchscreen i5-1135G7 16GB 256GB 1 év garancia, 4G LTE OPCIÓ
- Minden szoftver mellé teljesen audit és NIS2 biztos, jogilag hiteles licencigazolást adunk át!
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
