1. Python / Говнокод #29164

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    n = int(input())
    d = n
    i = 0
    a = 0
    c = 0
    has1 = False
    has2 = False
    has3 = False 
    has4 = False
    has5 = False
    has6 = False
    has7 = False
    has8 = False
    last_dig = 0
    while n > 0:
        last_dig = n % 10
        if last_dig > i :
            i = last_dig
            if last_dig == 1:
                c = 1
        elif last_dig == 1:
            has1 = True
        elif last_dig == 2:
            has2 = True
        elif last_dig == 3:
            has3 = True
        elif last_dig == 4:
            has4 = True
        elif last_dig == 5:
            has5 = True
        elif last_dig == 6:
            has6 = True
        elif last_dig == 7:
            has7 = True
        elif last_dig == 8:
            has8 = True
        n = n // 10
    c = d % 10
    if has1 == True and c >= 1:
        a = 1
    elif has2 == True and c >= 2:
        a = 2
    elif has3 == True and c >= 3:
        a = 3
    elif has4 == True and c >= 4:
        a = 4
    elif has5 == True and c >= 5:
        a = 5
    elif has6 == True and c >= 6:
        a = 6
    elif has7 == True and c >= 7:
        a = 7
    elif has8 == True and c >= 8:
        a = 8
    else:
        a = c
    print('Максимальная цифра равна', i)
    print('Минимальная цифра равна', a)

    Дано натуральное число n. Напишите программу, которая определяет его максимальную и минимальную цифры

    Запостил: Permanent_Record, 28 Июля 2025

    Комментарии (1) RSS

    Добавить комментарий