По разделам

 

Решение задачи Series 14


Дано целое число K и набор ненулевых целых чисел; признак его
завершения — число 0. Вывести количество чисел в наборе, меньших K.

Код (C/C++)

#include <stdio.h>
int main(void)
{
    int k,r=1,num=0;
    printf("K:");
    scanf("%i", &k);
    while (r!=0){
        printf(">");
        scanf("%i", &r);
        if (r<k) ++num;
    }
    printf("%i\n",num-1);
 
    return 0;
}

Код (Python)

import random

K = random.randrange(-3,5)
print("K = ",K)

x = random.randrange(1,10)
print(x,end='; ')
k = 0
if x < K:
    k += 1
while x != 0:
    if x < K:
        k += 1
    x = random.randrange(-5,6)
    print(x,end='; ')
    
print()
print("Amount of numbers less than K:",k)
									

Код (Pascal)

program Series14;
var
  i,R,K:Longint;
begin
write('Введите K : ');
readln(K);
R:=1;
i:=0;
  while(R<>0) do
   begin
     write('Введите число из набора: ');
     Readln(R);
     if R<K then i:=i+1;
   end;
  i:=i-1;
  Writeln(i);
  readln;
end.
									




Series. Абрамян
Series 1 Просмотров: 4391
Series 2 Просмотров: 2233
Series 3 Просмотров: 2007
Series 4 Просмотров: 2172
Series 5 Просмотров: 2052
Series 6 Просмотров: 2614
Series 7 Просмотров: 2894
Series 8 Просмотров: 3198
Series 9 Просмотров: 1865
Series 10 Просмотров: 2321
Series 11 Просмотров: 1751
Series 12 Просмотров: 2088
Series 13 Просмотров: 1520
Series 14 Просмотров: 1419
Series 15 Просмотров: 1702
Series 16 Просмотров: 2115
Series 17 Просмотров: 1916
Series 18 Просмотров: 2750
Series 19 Просмотров: 2443
Series 20 Просмотров: 1489
Series 21 Просмотров: 1682
Series 22 Просмотров: 1631
Series 23 Просмотров: 2018
Series 24 Просмотров: 1855
Series 25 Просмотров: 1423
Series 26 Просмотров: 1259
Series 27 Просмотров: 1199
Series 28 Просмотров: 1144
Series 29 Просмотров: 1164
Series 30 Просмотров: 1201
Series 31 Просмотров: 1158
Series 32 Просмотров: 1675
Series 33 Просмотров: 952
Series 34 Просмотров: 997
Series 35 Просмотров: 1379
Series 36 Просмотров: 1486
Series 37 Просмотров: 921
Series 38 Просмотров: 1238
Series 39 Просмотров: 877
Series 40 Просмотров: 1214

Комментарии

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



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