По разделам

 

Решение задачи If 15


Даны три числа. Найти сумму двух наибольших из них.

Код (C/C++)

#include <stdio.h>

int main(void)
{
   float a1, a2, a3,sum;
   printf("1:");
   scanf ("%f", &a1);
   printf("2:");
   scanf ("%f", &a2);
   printf("3:");
   scanf ("%f", &a3);

    if ((a1>=a2) & (a1>=a3)){
        if (a2>=a3){
            printf("%f\n",a1+a2);
        } else printf("%f\n",a1+a3);
    } else if ((a2>=a1) & (a2>=a3))
        if (a1>=a3){
            printf("%f\n",a1+a2);
        } else printf("%f\n",a2+a3);
    else
        if (a1>=a2){
            printf("%f\n",a1+a3);
        } else printf("%f\n",a2+a3);
   return 0;
}

Код (Python)

import random

A = random.randrange(-30,30)
B = random.randrange(-30,30)
C = random.randrange(-30,30)

print("Число A:", A)
print("Число B:", B)
print("Число C:", C)

if (C <= A and A <= B) or (C <= B and B <= A):
    m = A + B
elif (B <= A and A <= C) or (B <= C and C <= A):
    m = A + C
elif (A <= C and C <= B) or (A <= B and B <= C):
    m = B + C

print()    
print("Сумма:", m)
									

Код (Pascal)

program If15;
var
  A, B, C: Real;
begin
  Write('Введите первое число: ');
  Readln (A);

  Write('Введите второе число: ');
  Readln (B);

  Write('Введите третье число: ');
  Readln (C);

  if (A<=B) and (A<=C) then Writeln(B+C)
  else if (B<=A) and (B<=C) then Writeln(A+C)
  else if (C<=A) and (C<=B) then Writeln(A+B);

end.
									

Дополнительно

a = map(int, input().split())
a = list(a)
print(a[1] + a[2])
									



If. Абрамян
If 1 Просмотров: 14879
If 2 Просмотров: 9249
If 3 Просмотров: 9011
If 4 Просмотров: 10302
If 5 Просмотров: 10718
If 6 Просмотров: 57396
If 7 Просмотров: 6673
If 8 Просмотров: 6412
If 9 Просмотров: 6874
If 10 Просмотров: 7169
If 11 Просмотров: 6079
If 12 Просмотров: 57285
If 13 Просмотров: 7134
If 14 Просмотров: 6498
If 15 Просмотров: 6378
If 16 Просмотров: 5931
If 17 Просмотров: 3743
If 18 Просмотров: 5414
If 19 Просмотров: 5116
If 20 Просмотров: 8145
If 21 Просмотров: 5396
If 22 Просмотров: 4544
If 23 Просмотров: 5697
If 24 Просмотров: 5737
If 25 Просмотров: 4409
If 26 Просмотров: 6432
If 27 Просмотров: 5483
If 28 Просмотров: 6416
If 29 Просмотров: 4766
If 30 Просмотров: 5264

Комментарии

Чтобы написать комментарии вам нужно войти в систему или зарегистрироваться



Заявка на расчет