Вопрос задан 06.12.2023 в 01:44. Предмет Информатика. Спрашивает Чичинев Андрей.

Ввести строку, ввести два числа nach и kon. Определить, образует ли число подстрока, начинающаяся с

символа номер nach и заканчивающаяся символом номер kon. Желательно с объяснением.
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Мырзахметова Жанна.

Ответ:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApp21

{

   class Program

   {

       static void Main(string[] args)

       {

           string otvet = "да";

           while (otvet == "да")

           {

               /*ЯЗЫК ПРОГРАММИРОВАНИЯ C#*/

               Random rnd = new Random();

               int a = rnd.Next(0, 100); /*выдаётся рандомное число от 0 до 99. Можно поставить другое. Просто изменить 100.*/

               int b = rnd.Next(0, 10); /*1 половина. Можно поставить другое. Просто изменить 10.*/

               int btwo = rnd.Next(0, 10); /*2 половина. Можно поставить другое. Просто изменить 10.*/

               if (a - b * 10 == btwo) /*если рандомное число - 1 половину умноженную на 10 = 2 половине то выводим числа совпадают а если наоборот то выводим что не совпадают. В конце выводит рандом число и нужное число.*/

               {

                   Console.WriteLine("Число совпадает!");

                   Console.WriteLine(a);

                   Console.WriteLine(b + "" + btwo);

               }

               else

               {

                   Console.WriteLine("Число не совпадает!");

                   Console.WriteLine(a);

                   Console.WriteLine(b + "" + btwo);

               }

               Console.WriteLine("продолжить? да/нет");

               otvet = Console.ReadLine();

           }

       }

   }

}

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Input Validation and Substring Check in Python

To determine if a given string forms a substring that starts at index `nach` and ends at index `kon`, we can use Python's string slicing and comparison operations.

Here's a Python function that accomplishes this:

```python def is_substring(string, nach, kon): substring = string[nach:kon+1] return substring in string ```

Let's break down the function: - `string[nach:kon+1]`: This uses Python's slicing notation to extract the substring from index `nach` to index `kon`. Note that `kon+1` is used to include the character at index `kon`. - `substring in string`: This checks if the extracted substring exists within the original string and returns `True` if it does, indicating that the substring is indeed present.

For example, if we have a string `example_string = "Hello, World!"` and we want to check if the substring from index 3 to index 7 (inclusive) is present, we can call the function like this: ```python result = is_substring("Hello, World!", 3, 7) print(result) # Output: True ```

This will return `True` because the substring "lo, Wo" exists within the original string.

This approach leverages Python's built-in string manipulation capabilities to efficiently check for the presence of a specific substring within a given string.

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос