По разделам

 

Решение задачи 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 Просмотров: 14765
If 2 Просмотров: 9155
If 3 Просмотров: 8935
If 4 Просмотров: 10210
If 5 Просмотров: 10627
If 6 Просмотров: 57328
If 7 Просмотров: 6602
If 8 Просмотров: 6351
If 9 Просмотров: 6805
If 10 Просмотров: 7120
If 11 Просмотров: 6034
If 12 Просмотров: 57228
If 13 Просмотров: 7039
If 14 Просмотров: 6431
If 15 Просмотров: 6301
If 16 Просмотров: 5888
If 17 Просмотров: 3691
If 18 Просмотров: 5360
If 19 Просмотров: 5064
If 20 Просмотров: 8061
If 21 Просмотров: 5334
If 22 Просмотров: 4498
If 23 Просмотров: 5630
If 24 Просмотров: 5661
If 25 Просмотров: 4358
If 26 Просмотров: 6375
If 27 Просмотров: 5439
If 28 Просмотров: 6372
If 29 Просмотров: 4714
If 30 Просмотров: 5197

Комментарии

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



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