Перейти к основному содержанию
EDU-MMCS
Вы используете гостевой доступ (Вход)

cs101 ОП / Basics of programming ENG

  1. В начало
  2. Курсы
  3. Осенний семестр
  4. Фундаментальная информатика и ИТ
  5. cs101 ENG
  6. 1 topic. Basic constructions and loops
  7. Lesson #5. IF statement Part II. Max and Min

Lesson #5. IF statement Part II. Max and Min

Требуемые условия завершения
Открыто: Tuesday, 24 September 2019, 00:00

Lections

Follow the rules:

  • Save your files with the names of the task (e.g. task-04.pas)
  • Give meaning names to your variables
  • Use the comments to make the program clear for user
  • Give the task of the program in the form of a comment before the program code. For comments use curly brackets: 
1
  • Give the results of your program (log) in the form of a comment after the program code. It’s easy to do by simply copying. For comments use curly brackets:

    1

Search for minimum and maximum

  1. Which of the two variables is greater:

  2. Make the task number 0 (task-00-if.pas).

  3. Which of the two variables is greater and which one is less:

Make the tasks number 01 and 02 (task-01-if.pas, task-02-if.pas).

Random function

Random function is often used in Pascal.

To generate numbers from 0 to n not including the value of n itself (integers in the interval [0,N)), you must write:

random (n);

To get random number in range from a to b use the formula:

 x:=random(b-a+1)+a;

Tasks

0. {0.3 points} [task-00-if.pas] Three integers are given. Find the maximum (the greatest) number among the three entered numbers.

1.{0.3 points} [task-01-if.pas] Two real numbers are given. Find the maximum (the greatest) and minimum (the least) number among them. Output max and min.

Example:
-5.2, 74.6 >>> max=74.6, min=-5.2
25.7, 14.7 >>> max=25.7, min=14.7
2. {0.3 points} [task-02-if.pas]  A two-digit number is given. Find the minimum and the maximum among its digits and swap the digits in the number.

Example:

74  >>>  max = 7, min = 4, swapped = 47
25  >>>  max = 5, min = 2, swapped = 52
3.  {0.3 points}[task-03-if.pas] For given real numbers a and b find the value of the following function y. For y use real variable:

2

4. {0.3 points}[task-04-if.pas] For a given real x find the value of the following function f. For f use real variable:

1

5. {0.4 points}[task-05-if.pas] For a given real x find the value of the following function f:


6. {0.4 points}[task-06-if.pas] The integers a, b, c are given, which are the sides of a tríangle. Print True if the triangle with sides a, b, c is isósceles (равнобедренный), and print False otherwise.

7. {0.5 points}[task-07-if.pas] An integer is given. Display its description in the following form: “negative even number” or “negative odd number” or “zero number” or “positive odd number” or “positive even number”. Check the correctness of your program, provide a log of the program in the form of a comment.

Example:

-5 >>> negative odd number
6 >>> positive even number

8. [task-08-if.pas] The numbers X and Y are given. Print True if the point with coordinates (X, Y) lies in the fourth coordinate quarter and print False otherwise. Do not use conditional if-statement.

9. [task-9-if.pas] The coordinates X and Y of the chessboard field are given (integers lying in the range of 1–8). Considering that the bottom left cell of the board (1, 1) is black, output True if the field of X and Y is white and print False otherwise.

10. {0.8 points}[task-10-if.pas] Three integers are given. Find the number (quantity) of positive numbers among them. Example:

-1, -18, -9 >>> 0
-4,  -8, 12 >>> 1
 0, 11, 2 >>> 2
 7,  15, 1 >>> 3 
Note. It is convenient to use an auxíliary variable of integer type.

11. {0.8 points}[task-11-if.pas] Three integers are given. Find the number (quantity) of numbers among them that match the inequality  10 < numb < 20. Example:

-1, -18, 11 >>> 1
5,  17, 12 >>> 2
 0, 9, 7 >>> 0

12. {0.8 points}[task-12-b.pas] Three real numbers are given. Print true if none of these numbers are positive and False otherwise. Check the correctness of your program with at least three input data sets, give the log of the program in the form of a comment.

Example:
-1, -18, -9 >>> True
-4,  -8, 12 >>> False
 0, -11, -2 >>> True
 0,   0,  0 >>> True
 7,  15, -1 >>> False 

Extra tasks:

13. {1.2 points}[task-13-extra-b.pas] The integers A, B and k are given. At first output the larger of A and B, then the lesser of them. Print True if the difference between the numbers does not exceed the value of k and print False otherwise. Check the correctness of your program with at least three input data sets, give the log of the program in the form of a comment.

Example:
A = 15, B = 17, k =  2 >>> 17, 15, True
A =  6, B = -2, k =  5 >>>  6, -2, False
A = 11, B = 11, k =  0 >>> 11, 11, True
A = 15, B = 16, k =  0 >>> 16, 15, False

14.{0.3 points} [task-14-extra-if.pas] A three-digit integer is given. Find the maximum (the greatest) digit and minimum (the least) digit among the three digits of the given number and swap them. Output the numbers.

input: 374  =>  output: min=3, max=7, swapped number=734

15. {0.8 points} [task-15-extra-if.pas] Three integers are given. Find the maximum (the greatest) number and minimum (the least) among the three entered numbers. Output max and after it output min.

Note. Try to use as few comparison operations as possible. Use the output operator only once - at the end of the program, for this you need to memorize the desired numbers in additional variables.

Example:
input: -5,   74,  3 output:   -5, 74
 input: 3,    0,  0 output:    0,  3
input: 25, -100, 14 output: -100, 25


Extra task 2:

1. {0.8 point}[extra-task-01-if-b.pas] Two integer - the coordinates of the point on the plane are given. Print 0 if the point coincides with the (0,0) coordinate. If the point does not coincide with the the (0,0) coordinate, but lies on the OX or OY axis, print 10 or -10, respectively. Print 11 if the point does not lie on the coordinate axes.

Note. Implement the program so that the output operator is used only once to output a number that describes the position of a point on the coordinate plane.

2. {0.8 point}[extra-task-02-if.pas] For given real x find the value of the following function f the argument of which is an integer:

1

3. {1 point}[extra-task-01-if-b.pas] The integers a, b, c are given. Print True if there is a triangle with the corresponding lengths of the sides and print False otherwise. If the triangle exists so print its area.

Note. Recall the inequality of the triangle (the length of either side of a triangle is less than the sum of the lengths of the other two sides). To calculate the area, use the Heron formula (p means a semi-perimeter):

S=√p(p−a)(p−b)(p−c)
◄ Lesson #4. Condition operator & branches. IF statement Part I (19/09)
Hometask (until 6/10) ►
Пропустить Навигация
Навигация
  • В начало

    • Страницы сайта

      • Мои курсы

      • Теги

    • Мои курсы

    • Курсы

      • Осенний семестр

        • Прикладная математика и информатика

        • Фундаментальная информатика и ИТ

          • Compiler Development

          • КПР

          • АЗПК

          • Frontend

          • ТеорЯП

          • Ruby Eng

          • EngCA&OS

          • CS201e

          • Компиляторы - лекции

          • CS202

          • CS211 C++ ENG

          • cs101 ENG

            • Общее

            • 1 topic. Basic constructions and loops

              • ЗаданиеLesson #1. Introduction to PascalABC.NET

              • ЗаданиеLesson #2. Integers, div and mod operators

              • ЗаданиеLesson #3. Boolean Expressions And Conditions

              • ЗаданиеLesson #4. Condition operator & branches. IF s...

              • ЗаданиеLesson #5. IF statement Part II. Max and Min

              • ЗаданиеHometask (until 6/10)

              • ЗаданиеFormatted output using WritelnFormat

              • ЗаданиеLesson #6. Chained IF statements and Case statemen...

              • ЗаданиеLesson #7. Loops

              • ЗаданиеLesson #8. For Loop

              • ЗаданиеLesson #9. Sum, Accumulators, Product and Counter....

              • ЗаданиеLesson #10. Minimum or Maximum value of N numbers

              • ЗаданиеLesson #11. While & Repeat Loops

              • ЗаданиеLesson #12. While & Repeat Loops: digits of a ...

              • ЗаданиеLesson #13. Procedures

              • ЗаданиеLesson #14. Functions

              • ЗаданиеTest Loops (control test)

            • Тема 2

            • Тема 3

            • Тема 4

            • Тема 5

            • Тема 6

            • Тема 7

            • Тема 8

            • Тема 9

            • Тема 10

        • Математика, механика

        • Педагогическое образование

        • Магистратура

          • Разработка мобильных приложений и компьютерных игр

        • Аспирантура

        • Вечернее отделение

        • Другое

      • Весенний семестр

        • Прикладная математика и информатика

        • Фундаментальная информатика и ИТ

        • Математика, механика

        • Педагогическое образование

        • Магистратура

          • Разработка мобильных приложений и компьютерных игр

        • Аспирантура

        • Вечернее отделение

        • Другое

      • Воскресная компьютерная школа

        • Пользователь компьютера плюс

        • Пользователь прикладных программ

        • Программирование I ступень

        • Программирование II ступень

        • Программирование III ступень

        • Архив

      • Воскресная математическая школа

        • Олимпиадная математическая школа

        • Открытое тестирование - 2023 г.

        • Открытое тестирование - 2022 г.

        • Повышение квалификации

        • Архив

        • Доступная математика

        • ВМШ - 22

      • Государственная итоговая аттестация

      • Дополнительное образование

      • Олимпиады

      • Видеолекции

      • Разное

      • Архив курсов

Вы используете гостевой доступ (Вход)
cs101 ENG
Сводка хранения данных
Скачать мобильное приложение Яндекс.Метрика