По разделам

 

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


Дано целое число N (> 1) и набор из N вещественных чисел. Проверить, образует ли данный набор возрастающую последовательность. Если
образует, то вывести TRUE, если нет — вывести FALSE.

Код (C/C++)

#include <stdio.h>
int main(void)
{
    int n;
    printf("N:");
    scanf("%i", &n);
    int i,rez=1;
    float r,r1;
    for (i=1; i<=n; ++i, r1=r){
        printf(">");
        scanf("%f", &r);
        if ((r1>r)&&(i!=1)) rez=0;
    }
    printf("%s\n",rez?"True":"False");
    return 0;
}

Код (Python)

import random

N = random.randrange(2,20)
print("N = ",N)

#x = 1
x = random.randrange(1,10)
x_prev = x
flag = True
for i in range(1,N):
    #x = i+1
    x = random.randrange(1,10)
    if x_prev >= x:
        flag = False
        #break
    print(x_prev,end="; ")
    x_prev = x
print(x)

print("Result = ",flag)
									

Код (Pascal)

program Series21;
var
  i,N,Num,Num1,El :Integer;
  b:boolean;
begin
 b:=TRUE;
 El:=0;
 Write('N:');
 Readln(N);
 for i:=1 to N do
   begin
    write('Введите ',i,' элемент последовательности :');
    Readln(Num);
    if (((Num1>Num) and (i<>1)) and b) then
     begin
      El:=Num;
      b:=FALSE;
     end;
     Num1:=Num;
   end;
  Writeln(El);
end.
									

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

n = int(input())
temp = float(input())
t = temp
b = True
for i in range(n - 1):
    temp = float(input())
    if temp < t:
        b = False
    t = temp
print(b)
									



Series. Абрамян
Series 1 Просмотров: 4441
Series 2 Просмотров: 2267
Series 3 Просмотров: 2034
Series 4 Просмотров: 2217
Series 5 Просмотров: 2091
Series 6 Просмотров: 2672
Series 7 Просмотров: 2933
Series 8 Просмотров: 3227
Series 9 Просмотров: 1913
Series 10 Просмотров: 2363
Series 11 Просмотров: 1774
Series 12 Просмотров: 2129
Series 13 Просмотров: 1556
Series 14 Просмотров: 1446
Series 15 Просмотров: 1733
Series 16 Просмотров: 2144
Series 17 Просмотров: 1955
Series 18 Просмотров: 2783
Series 19 Просмотров: 2489
Series 20 Просмотров: 1539
Series 21 Просмотров: 1709
Series 22 Просмотров: 1654
Series 23 Просмотров: 2053
Series 24 Просмотров: 1885
Series 25 Просмотров: 1453
Series 26 Просмотров: 1289
Series 27 Просмотров: 1221
Series 28 Просмотров: 1169
Series 29 Просмотров: 1189
Series 30 Просмотров: 1229
Series 31 Просмотров: 1183
Series 32 Просмотров: 1702
Series 33 Просмотров: 978
Series 34 Просмотров: 1025
Series 35 Просмотров: 1405
Series 36 Просмотров: 1514
Series 37 Просмотров: 947
Series 38 Просмотров: 1267
Series 39 Просмотров: 896
Series 40 Просмотров: 1242

Комментарии

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



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