For3. Даны два целых числа A и B (A < B). Вывести в порядке убывания все целые числа, расположенные между A и B (не включая числа A и B), а также количество N этих чисел.
Решение Python
1 2 3 4 5 6 7 8 9 10 11 12 | # Input integers A and B A = int(input("Enter the value of A: ")) B = int(input("Enter the value of B: ")) # Calculate the count of numbers between A and B count = B - A - 1 # Output the numbers and their count print(f"The numbers between {A} and {B} in descending order are:") for num in range(B - 1, A, -1): print(num, end=" ") print(f"\nTotal count of numbers: {count}") |
>
Решение Pascal
1 2 3 4 5 6 7 8 9 10 11 12 | program For3; var A,B, i:Integer; begin Write('Введите A: '); Readln(A); Write('Введите B: '); Readln(B); For i:=1 to B-A-1 do Writeln(B-i); Writeln('Кол-во: ',B-A-1); end. |
>
Решение C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <stdio.h> int main(void) { int a, b; printf("A:"); scanf ("%i", &a); printf("B:"); scanf ("%i", &b); int i; for (i = b-1; i>a; --i) printf("%i\n",i); printf("N: %i\n", b-a-1); return 0; } |
Решение C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <iostream> using namespace std; int main(){ int a, b; cout << "A:"; cin >> a; cout << "B:"; cin >> b; for (int i = b-1; i>a; --i) cout << i << endl; cout << b-a-1; return 0; } |
Решение C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | using System; namespace ConsoleApp { class Program { static void Main(string[] args) { Console.Write("a="); int a = Convert.ToInt32(Console.ReadLine()); Console.Write("b="); int b = Convert.ToInt32(Console.ReadLine()); for (int i = b - 1; i > a; i--) Console.WriteLine(i); Console.WriteLine(b - a - 1); Console.ReadKey(); } } } |
>
Решение Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | package abramyan; import java.util.Scanner; public class Abramyan { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("a="); int a = in.nextInt(); System.out.print("b="); int b = in.nextInt(); for (int i = b - 1; i > a; i--) System.out.println(i); System.out.println(b - a - 1); in.close(); } } |
А есть Питон?
Нашли?
fun main(){
var a=10
var b=20
for (i in a+1..b-1){
println(i)
}
var n=b-a-1
print(n)
}
kotlin
хато братишка, задание внимательно хон DD
fun main() {
val A = 10
val B = 20
for(i in B-1 downTo A+1){
println(i)
}
println(B-A-1)
}
//SWIFT
let A = 10
let B = 20
for i in A+1…B-1 {
print(i)
}
print(B-A-1)
python плиииз!
Нашли?
using System;
public class Example
{
public static void Main()
{
Console.Write(«Введите число А = «);
int a = Convert.ToInt32(Console.ReadLine());
Console.Write(«Введите число В = «);
int b = Convert.ToInt32(Console.ReadLine());
int i;
for (i=0; i<=(b-a); i++)
{
Console.WriteLine(b — i);
}
Console.WriteLine(i);
Console.ReadKey();
}
}
Можно small basic
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int n = 0;
for (int i = a; i>=b; i—){
System.out.println(i);
n = a-b+1;
}
System.out.println(n);
#python
A=2
B=10
print(‘Числа в порядке убывания:’)
for i in range(B — 1,A, -1):
if i ==(A or B):
continue
print(i)
C=B-A
print(‘Чисел между ними:’,C-1)