Venjin
26.12.2021 00:11

#include using namespace std;
//5 3 6 2 1
int second_max(int *arr, int n) {
int max_index = 0;//max = 5
for(int i = 1; i < n; i++) {
if(arr[i] > arr[max_index])
max_index = i;
}

int max2 = arr[0];
for(int i = 0; i < n; i++) {
if(i == max_index)
continue;
if(arr[i] > max2) {
max2 = arr[i];
}
}
return max2;
}

//HOME Task
double getAverage(int *arr, int n) {
return 0;
}

int second_max(int *arr, int n) {
return 0;
}

int sum(int *arr, int n) {
return 0;
}

int find(int *arr, int n, int key) {
return the index of key, otherwise
return -1;
}

void mysort(int *arr, int n) {

}

int main() {
int arr[5];

for(int i = 0; i < 5; i++) {//i = 0
arr[i] = i+1;
}
int n = sizeof(arr)/sizeof(int);
cout << second_max(arr, n) << endl;
cout << find(arr, n, 5) << endl;
//4
}
/*

bool, char, int, float, double, long
size/range
int -> 4 bytes, 4bytes -> bit

arithmetic: + - * / %
assignment: =, +=, -=, ...
logical: !, ||, &&
relational: >, <, <=, >=, ==, !=
auto incr/decr: ++, --
bitwise: |, &, xor

selection structure: if else, switch case, ternary op
loop structure: while, for, do while
*/


#include using namespace std; //5 3 6 2 1 int second_max(int *arr, int n) { int max_index = 0;//max

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
мпппеекк1
07.12.2022 11:01

Программа:

Python:

from random import randint

pts = 100

while pts > 0:

  num, bet = map(int, input('Введите число от 2 до 12 и ставку: ').split())

  if bet > pts:  print(f'У вас не хватает очков! Вы имеете {pts} очков.')

  else:

      cube1, cube2 = randint(1,6), randint(1,6)

      print(f'Первый куб: {cube1}, второй куб: {cube2}')

      summ = cube1 + cube2

      if (summ < 7 and num < 7) or (summ > 7 and num > 7):

          pts += bet

          print(f'Ваша ставка ! Теперь у вас {pts} очков.')

      elif summ == num:

          pts += bet * 4

          print(f'Ваша ставка ! Теперь у вас {pts} очков.')

      else:

          pts -= bet

          print(f'Ваша ставка не ! Теперь у вас {pts} очков.')

      if input('Желаете закончить игру (да/нет)? ').lower() == 'да':

          print(f'Вы закончили игру с {pts} очков.')

          break

0,0(0 оценок)
Ответ:
zooz7654Кристина
07.12.2022 11:01

from random import randint

points = 100

gameover = False

while not gameover and points > 0:

   print('Ваш баланс: ', points)

   while True:

       choice = int(input('Введите число на которое хотите поставить(2-12): '))

       if choice in range(2,13):

           break

       print('Ставка должна быть в диапазоне от 2 до 12!')

   while True:

       bet = int(input('Введите сумму ставки: '))

       if bet <= points:

           break

       print('Недостаточно для такой ставки!')

   points -= bet

   rand1 = randint(1,6)

   rand2 = randint(1,6)

   result = rand1 + rand2

   print('Выпали числа {} и {}. Сумма = {}'.format(rand1, rand2, result))

   if result == choice:

       print('Вы выиграли x4 свой ставки!')

       points += bet*4

   elif (result < 7 and choice < 7) or (result > 7 and choice > 7):

       print('Вы выиграли свою ставку!')

       points += bet * 2

   else:

       print('Вы проиграли ставку!')

   gameover = bool(input('Если хотите выйти, введите любой символ. Если хотите продолжить - нажмите Enter: '))

print('Game Over. У вас закончились или вы захотели выйти из игры.')

Объяснение:

0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота