static int Main() { int p(string s) => int.Parse(s); var i = C.ReadLine().Split(' '); int Z = p(i[0]), T = p(i[1]), X = p(i[2]), Y = p(i[3]); for (; ;) { var d = ""; if (T > Y) { d += "S"; Y++; } if (T < Y) { d += "N"; Y--; } if (Z > X) { d += "E"; X++; } if (Z < X) { d += "W"; X--; } C.WriteLine(d); } }
public Notebook(string surname, string name, string phoneNumber, string country) { while (surname == "") { Console.WriteLine("От меня не скроешься! Фамилия обязательное поле!!!!"); surname = Console.ReadLine(); } while (name == "") { Console.WriteLine("От меня не скроешься! Имя обязательное поле!!!!"); name = Console.ReadLine(); } while (country == "") { Console.WriteLine("От меня не скроешься! Страна обязательное поле!!!!"); country = Console.ReadLine(); } while (!Regex.IsMatch("[0-9]", phoneNumber) && phoneNumber.Length != 11) { Console.WriteLine("Мне нужен твой номер, состоящий из 11 цифр!"); phoneNumber = Console.ReadLine(); } this.surname = surname; this.name = name; this.phoneNumber = phoneNumber; this.country = country; }
static void Main(string[] args) { while (true) { try { C.WriteLine("请输入指令序列"); var commandSequence = C.ReadLine(); var result = Runner.Run(commandSequence.ToUpper()); C.WriteLine("结果:"); C.WriteLine(result); } catch (Exception ex) { C.WriteLine("指令错误!"); C.WriteLine(ex.Message); } C.WriteLine("继续?(输入Y继续,其他退出。)"); if (!string.Equals("Y", C.ReadLine(), StringComparison.OrdinalIgnoreCase)) { break; } } C.WriteLine("再见!"); }
private static string getString(string i_Type) { Console.WriteLine("Please enter {0}:", i_Type); string str = Console.ReadLine(); return(str); }
static void Main(string[] args) { var ecos = new ECoSConnect(); var ip = args[0]; new Thread(() => ecos.StartHandler(ip)).Start(); Thread.Sleep(500); SendTests(ecos); try { for (;;) { var lineToSend = C.ReadLine(); if (string.IsNullOrEmpty(lineToSend)) { continue; } lineToSend = lineToSend.Trim(); if (lineToSend.Length <= 0) { continue; } IsQuit(lineToSend); ecos.SendMessage(lineToSend); } } catch { ecos.Disconnect(); Environment.Exit(0); } }
static void Main(string[] args) { // gen(); Console.WriteLine("starting up pipeline"); setupPipeline(); Console.WriteLine("starting up actors"); var hocon = ConfigurationFactory.ParseString(@"akka { actor { provider = remote } remote { dot-netty.tcp { port = 8080 hostname = localhost } } }"); using (var akka = ActorSystem.Create("nlp-system", hocon)) { var actor = akka.ActorOf <NERActor>("ner"); var actor2 = akka.ActorOf <SentimentActor>("sent"); Console.WriteLine(actor.Path.ToString()); Console.ReadLine(); } }
public static void MainMenu() { Console.WriteLine("1. Meet the animals, " + "\n2. Work the farm, " + "\n3. Overthrow your totalitarian overlords in the name of " + "\n liberty only to inevitably become that which you swore to free yourself from" + "\n4. Feed the chickens"); var var5 = Console.ReadLine(); if (var5 == "1") { Menu.AnimalMenu(); } else if (var5 == "2") { FarmWork(); } else if (var5 == "3") { Overthrow(); } else if (var5 == "4") { FeedChickens(); } }
private static void GuessingGame() { Console.Clear(); Console.WriteLine("Guessing Game!"); Random myRandom = new Random(); int randomNumber = myRandom.Next(1, 11); int guesses = 0; bool incorrect = true; do { Console.WriteLine("Guess a number between 1 and 10: "); string result = Console.ReadLine(); guesses++; if (result == randomNumber.ToString()) { incorrect = false; } else { Console.WriteLine("Wrong!"); } } while (incorrect); Console.WriteLine("Correct! It took you {0} guesses.", guesses); Console.ReadLine(); }
public static void PigActions() { Console.WriteLine("Pig 1, Pig 2, or Pig 3, Return 4"); var var2 = Console.ReadLine(); if (var2 == "1") { Console.WriteLine("The first pig says \"Oink\""); ReturntoPigs(); } else if (var2 == "2") { Console.WriteLine("The second pig rolls in the mud"); ReturntoPigs(); } else if (var2 == "3") { Console.WriteLine("Napoleon the pig says \"All animals are equal, " + "but some animals are more equal than others\"...Oink"); ReturntoPigs(); } else if (var2 == "4") { Console.Clear(); Menu.AnimalMenu(); } //else if (var2 == "5") //{ // Menu.AnimalMenu(); //} }
static void Main(string[] args) { // Получить с консоли значение трех целых чисел // Выбрать наибоьшее из трех чисел // Вывести на консоль // Сравнить число на четность с помощью свич // Проверить на размер < 100 с помощью быстрой проверки int a, b, c = 0; Console.WriteLine("Вам нужно ввести три разных числа:"); Console.Write("Введите первое число: "); a = EvenNumber(Convert.ToInt32(Console.ReadLine())); Console.Write("Введите второе число: "); b = EvenNumber(Convert.ToInt32(Console.ReadLine())); Console.Write("Введите третие число: "); c = EvenNumber(Convert.ToInt32(Console.ReadLine())); Console.Clear(); Console.WriteLine($"Вы ввели: {a}, {b}, {c}"); NumberCheck(a, b, c); Console.ReadLine(); }
private static bool MainMenu() { Console.Clear(); Console.WriteLine("Choose an option:"); Console.WriteLine("1) Print Numberz Game"); Console.WriteLine("2) Guessing Game"); Console.WriteLine("3) Exit"); string result = Console.ReadLine(); if (result == "1") { PrintNumbers(); return(true); } if (result == "2") { GuessingGame(); return(true); } if (result == "3") { return(false); } return(true); }
static void Rand() { try { Console.WriteLine("Enter 3 numbers"); int input1 = Convert.ToInt32(Console.ReadLine()); int input2 = Convert.ToInt32(Console.ReadLine()); int input3 = Convert.ToInt32(Console.ReadLine()); int[] arr = new int[] { input1, input2, input3 }; for (int i = 0; i < arr.Length; i++) { if ((int)arr[i] < 10) { Console.WriteLine((int)arr[i]); } } } catch (SystemException) { Console.WriteLine("Invalid input"); Rand(); } Console.ReadLine(); }
static void Main(string[] args) { Multiplication(-5, 6); Division(35, 7); Console.ReadLine(); //List<int> numbers = new List<int>(); //Console.WriteLine("Enter numbers to add to a list"); //int input = Convert.ToInt32(Console.ReadLine()); //while (input != 0) //{ // numbers.Add(input); // continue; //} //Console.WriteLine(numbers); ////Subtraction //int y2 = 120; //int z2 = 100; //int tmp2 = -(z2); //int sum2 = y2 + tmp2; //Console.WriteLine(sum2); }
private static void Main() { Task.Factory.StartNew(RefreshTitle); while (true) { Console.ForegroundColor = Settings.Default.MessageForeground; string oldTask = ReadLastTask(); Console.WriteLine(Settings.Default.Label); Console.ForegroundColor = Settings.Default.TaskForegroundColor; Console.WriteLine(oldTask); Console.ForegroundColor = Settings.Default.MessageForeground; Console.WriteLine(Settings.Default.NewTaskMessage); Console.ForegroundColor = Settings.Default.TaskForegroundColor; string newTask = Console.ReadLine(); if (string.IsNullOrEmpty(newTask)) { newTask = oldTask; } SaveTask(newTask); Console.Clear(); Console.ForegroundColor = Settings.Default.MessageForeground; Console.Write(Settings.Default.SavingMessage); for (int i = 0; i < 3; ++i) { Thread.Sleep(Settings.Default.SaveDelay); Console.Write('.'); } Console.WriteLine(); Console.WriteLine(Settings.Default.SaveMessage); Thread.Sleep(Settings.Default.PostSaveDelay); Console.Clear(); } }
static void Main(string[] args) { var jarRoot = @"F:\Downloads\stanford-postagger-full-2015-01-30"; var modelsDirectory = jarRoot + @"\models"; // Loading POS Tagger var tagger = new MaxentTagger(modelsDirectory + @"\wsj-0-18-bidirectional-nodistsim.tagger"); // Text for tagging var text = "I'm not happy."; var sentences = MaxentTagger.tokenizeText(new StringReader(text)).toArray(); foreach (ArrayList sentence in sentences) { var taggedSentence = tagger.tagSentence(sentence); Iterator it = taggedSentence.iterator(); while (it.hasNext()) { var item = it.next().ToString(); var split = item.Split('/'); var word = split[0]; var pos = split[1]; Console.WriteLine("Word:" + word + " POS:" + pos); } Console.ReadLine(); } }
static void Main(string[] args) { //to limit any possibility to run injection in EXE if (args.Length != 0) { throw new ArgumentException("Invalid Arguments set, there is to many arguments... \n\nThis program does not require Arguments to run!"); } Rover carRover = UserInputs.StartUp(); do { Console.Write("Command Input: "); var command = Console.ReadLine()?.ToUpper(); if (command.ValidateCommandInput()) { var finalStatus = carRover.ExecuteCommand(command); Console.WriteLine($"{finalStatus.IsCommandValid}, {(char)finalStatus.FinalOrientation}, ({finalStatus.FinalPosition.XPosition},{finalStatus.FinalPosition.YPosition})"); Environment.Exit(0); } else { Console.WriteLine("Command not valid, try again....\n"); } } while (true); }
public IHotDrink MakeDrink() { Console.WriteLine("Available drinks"); for (var index = 0; index < namedFactories.Count; index++) { var tuple = namedFactories[index]; Console.WriteLine($"{index}: {tuple.Item1}"); } while (true) { string s; if ((s = Console.ReadLine()) != null && int.TryParse(s, out int i) && // c# 7 i >= 0 && i < namedFactories.Count) { Console.Write("Specify amount: "); s = Console.ReadLine(); if (s != null && int.TryParse(s, out int amount) && amount > 0) { return(namedFactories[i].Item2.Prepare(amount)); } } Console.WriteLine("Incorrect input, try again."); } }
public void Run(IInterrogator <DataSet> interrogator) { subscription = interrogator.DataProvider.Subscribe(this); interrogator.Start(); string command; do { SystemConsole.WriteLine(); using (new ConsoleFormatter(ConsoleColor.DarkRed, ConsoleColor.White)) { SystemConsole.WriteLine("Type 'quit' to exit the application"); } using (new ConsoleFormatter(ConsoleColor.Gray, ConsoleColor.White)) { SystemConsole.WriteLine("Type 'refresh' to refresh views"); } command = SystemConsole.ReadLine(); if (command == "refresh") { interrogator.Refresh(); } } while (command != "quit"); interrogator.Stop(); }
private void HandleConsoleInput() { var input = Console.ReadLine(); while (input != "4") { switch (input) { case "1": AddPersonDialog(); break; case "2": GetPersonDialog(); break; case "3": Console.WriteLine($"Person count: {_personService.GetPersonCount()}"); break; default: Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Wrong option name!"); Console.ForegroundColor = ConsoleColor.Green; DrawUserInterface(); break; } input = Console.ReadLine(); } }
static void Main(string[] args) { ZKLockProviderTests test = new ZKLockProviderTests(); test.LockTest(); Ctrl.ReadLine(); }
public static void EnterNewVehicle(GarageLogic.GarageLogic i_Garage) { Vehicle vehicle = InitializeVehicle(); Dictionary <string, Dictionary <string, string[]> > vehiclesQuestionsDictionary = i_Garage.GetVehicleRequiredData(vehicle); string[] carTypes = new string[vehiclesQuestionsDictionary.Keys.Count]; vehiclesQuestionsDictionary.Keys.CopyTo(carTypes, 0); string carType = GetCarType(carTypes); Dictionary <string, string[]> questionsForUser = vehiclesQuestionsDictionary[carType]; Dictionary <string, object> setDataDictionary = new Dictionary <string, object>(); foreach (KeyValuePair <string, string[]> vehiclePair in questionsForUser) { Console.WriteLine(vehiclePair.Value[0]); Console.WriteLine("The type of answer: " + vehiclePair.Value[1]); string answer = Console.ReadLine(); object validAnswer = ParseAnswer(vehiclePair.Value[1], answer); while (validAnswer == null) { Console.WriteLine("Invalid type - {0} should be {1}", vehiclePair.Key, vehiclePair.Value[1]); Console.WriteLine(vehiclePair.Value[0]); answer = Console.ReadLine(); validAnswer = UI.ParseAnswer(vehiclePair.Value[1], answer); } setDataDictionary.Add(vehiclePair.Key, validAnswer); } Console.WriteLine(i_Garage.SetVehicleData(vehicle, setDataDictionary, carType)); }
static void Main(string[] args) { //Write a C# Sharp program to print the output of multiplication of three numbers which will be entered by the user. //Go to the editor // Test Data: // Input the first number to multiply: 2 // Input the second number to multiply: 3 // Input the third number to multiply: 6 // Expected Output: // 2 x 3 x 6 = 36 var numbers = new int[3]; var order = new string[3] { "first", "second", "third" }; for (var i = 0; i <= 2; i++) { Console.WriteLine("please enter the " + order[i] + " number"); numbers[i] = Convert.ToInt32(Console.ReadLine()); if (i == 2) { var total = numbers[0] * numbers[1] * numbers[2]; Console.WriteLine(numbers[0] + " x " + numbers[1] + " x " + numbers[2] + " = " + total); Console.WriteLine(""); } } }
private static string getAnswer() { Console.WriteLine("If you want to continue - press 1, to exit - press 2"); string answer = Console.ReadLine(); return(answer); }
static void Main(string[] args) { try { int yob; int mob; int dob; A.WriteLine("Enter the Year of your Birth"); yob = Convert.ToInt32(A.ReadLine()); A.WriteLine("Enter the Month of your Birth"); mob = int.Parse(A.ReadLine()); A.WriteLine("Enter the Day of your Birth"); dob = int.Parse(A.ReadLine()); validitycheck(yob, mob, dob); } catch (FormatException e) { A.WriteLine(e.Message); A.WriteLine("Enter the Accurate Credentials this time\n"); int yob; int mob; int dob; A.WriteLine("Enter the Year of your Birth"); yob = Convert.ToInt32(A.ReadLine()); A.WriteLine("Enter the Month of your Birth"); mob = int.Parse(A.ReadLine()); A.WriteLine("Enter the Day of your Birth"); dob = int.Parse(A.ReadLine()); validitycheck(yob, mob, dob); } }
public void add() { D.WriteLine("Enter Numbers to add : "); a = Convert.ToInt32(D.ReadLine()); b = Convert.ToInt32(D.ReadLine()); D.WriteLine("Result : " + (a + b)); }
public static void Main(string[] args) { L.Config .WriteTo.Console() .WriteTo.PoshConsole() .WriteTo.Trace() .WriteTo.AzureApplicationInsights("24703760-10ec-4e0b-b3ee-777f6ea80977", true); log.Critical("critical"); using (L.Context(KnownProperty.OperationId, Guid.NewGuid().ToShortest())) { using (L.Context( KnownProperty.RoleInstance, Guid.NewGuid().ToString(), KnownProperty.RoleName, "service one")) { string requestId = Guid.NewGuid().ToString(); string dependencyId = Guid.NewGuid().ToString(); log.Request("incoming", 1, null, KnownProperty.ActivityId, requestId); log.Dependency("http", "server", "correlate", 1, null, KnownProperty.ActivityId, dependencyId); log.Request("incoming@2", 1, null, KnownProperty.RoleName, "service two", KnownProperty.ParentActivityId, dependencyId); } } C.ReadLine(); }
static void Main(string[] args) { HeyoVirtualFile.VirtualFileSystem.ReleaseLib(); int pid = -1; //pid = int.Parse(Console.ReadLine()); while (pid == -1) { Process[] localByName = Process.GetProcessesByName("java"); if (localByName.Length > 0) { pid = localByName[0].Id; } } HeyoVirtualFile.VirtualFileSystem vfs = new HeyoVirtualFile.VirtualFileSystem(pid); vfs.Run(); vfs.AddPuppetFile(new FileMapping(@"D:\Virtual\Test.txt", @"D:\Virtual.txt")); vfs.AddPuppetFile(new FileMapping(@"D:\Virtual\Test666.txt", @"D:\Virtual.txt")); Console.WriteLine("Inject Success"); Console.WriteLine("现在你可以添加虚拟文件,输入格式: 实际文件路径 虚拟文件路径"); while (true) { string actual = Console.ReadLine(); string vir = Console.ReadLine(); vfs.AddPuppetFile(new FileMapping(vir, actual)); Console.WriteLine("添加成功"); } Console.ReadKey(); }
static void Main(string[] args) { //each commented block of code corresponds to every task Console.Write("temperature (celsius): "); double temperatureInCelsius = Convert.ToDouble(Console.ReadLine()); Console.Write("speed (m/s): "); double speedInMpS = Convert.ToDouble(Console.ReadLine()); (new EffectiveTemperature()).PrintEffectiveTemperature(temperatureInCelsius, speedInMpS); /*Console.Write("start: "); * int a = Convert.ToInt32(Console.ReadLine()); * * Console.Write("end: "); * int b = Convert.ToInt32(Console.ReadLine()); * * (new NumbersWithFourOnes()).PrintNumbersWithFourOnes(a, b);*/ /*Console.Write("digits string: "); * String digitsString = Console.ReadLine(); * * (new ISBN()).Print_ISBN(digitsString);*/ }
static void Main(string[] args) { /* * int x; * int y; * x = 7; * y = x + 3; * Console.WriteLine(y); * Console.ReadLine(); */ Console.WriteLine("What is your name?"); Console.Write("First name: "); string myFirstName; myFirstName = Console.ReadLine(); //string myLastName; //Console.Write("Last name: "); //myLastName = Console.ReadLine(); Console.WriteLine("Last name: "); string myLastName = Console.ReadLine(); Console.WriteLine("Hello, " + myFirstName + " " + myLastName); Console.ReadLine(); }
static void Main(string[] args) { // This reference is needed to ensure that the sqlite binaries get copied to // the output directory correctly. #pragma warning disable 168 SQLiteConnection connection; #pragma warning restore 168 Logger.SetOutputType(Logger.OutputType.Console); Logger.OutputLogLevel = Logger.LogLevel.Debug; // Initialize the runtime (load configuration, etc.) ServiceRuntime.Instance.Initialize(); ServiceRuntime.Instance.OnNotify += (sender, eventArgs) => { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("NOTIFY {0} from device {1} on server {2}", eventArgs.NotificationType, eventArgs.UpsContext.Name, eventArgs.UpsContext.UpsConfiguration.ServerConfiguration.DisplayName); Console.ResetColor(); }; // Start the WCF service and monitoring task ServiceRuntime.Instance.Start(); Console.WriteLine("Runtime is active. Press ENTER to terminate."); Console.ReadLine(); ServiceRuntime.Instance.Stop(); }