Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
internal class Program { static void Main(string[] args) { char openParenthesis = '('; char closedParenthesis = ')'; int countParenthesis = 0; int maxCountParenthesis = 0; Console.Write($"Введите строку из скобок '{openParenthesis}' и '{closedParenthesis}' - "); string userInput = Console.ReadLine(); foreach (char parenthesis in userInput) { if (parenthesis == openParenthesis) { countParenthesis++; if (countParenthesis > maxCountParenthesis) maxCountParenthesis = countParenthesis; } else { countParenthesis--; if (countParenthesis < 0) break; } } if (countParenthesis == 0) { Console.WriteLine($"строка корректная и максимум глубины равняется {maxCountParenthesis}"); } else { Console.WriteLine("Некорректная строка."); } Console.ReadKey(); } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)