Вопрос задан 06.05.2019 в 08:33. Предмет Информатика. Спрашивает Яковлев Алексей.

Блинчики, напомните, пожалуйста, как в паскале создать программу по выбору числа на "рандом". То

есть на вход мы получаем число равное количеству цифр, а вывести должны одно любое число....Кто понял мое корявое объяснение помогите пожалуйста^^
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Аксёнова Анастасия.
Writeln(Random(25)+1);
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Creating a Pascal Program to Generate a Random Number

To create a Pascal program that generates a random number, you can make use of the built-in `Random` function. Here's an example of how you can implement this:

```pascal program RandomNumberGenerator;

var randomNumber, inputNumber: Integer;

begin // Prompt the user to enter a number WriteLn('Enter a number:'); ReadLn(inputNumber);

// Set the seed for the random number generator Randomize;

// Generate a random number between 1 and the input number randomNumber := Random(inputNumber) + 1;

// Output the generated random number WriteLn('Random number:', randomNumber);

// Wait for user input before closing the program ReadLn; end. ```

In this program, the user is prompted to enter a number. The `Randomize` procedure is then called to initialize the random number generator with a unique seed value based on the current system time. Finally, the `Random` function is used to generate a random number between 1 and the input number, and the result is displayed on the screen.

Please note that the `Random` function generates pseudo-random numbers, which means that the sequence of numbers it generates will appear random but is actually deterministic. If you need a truly random number, you may need to use external libraries or hardware devices.

I hope this helps! Let me know if you have any further questions.

0 0

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

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

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