По разделам

 

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


Дано целое число N и набор из N целых чисел. Если в наборе
имеются положительные числа, то вывести TRUE; в противном случае
вывести FALSE.

Код (C/C++)

#include <bits/stdc++.h>
using namespace std;

int main() {
	srand((int)time(0));
	int N = rand() % 10 + 1;
	cout << "N = " << N << endl;
	
	int x;
	string result;
	for(int i = 0; i < N; i++) {
		x = rand() % 100 - 70;
		//cin >> x;
		result = (x > 0) ? "true" : "false";
		cout << x << " : " << result << endl;
		if(x > 0)
			break;
	}
	
	cout << endl;
	cout << "There is a positive number: " << result;
	cout << endl;

	return 0;
}

Код (Python)

import random

N = random.randrange(1,10)
print("N = ",N)
r = False
for i in range(N):
    x = random.randrange(-10,10)
    r = (x>0)
    print(x," : positive - ",r)
    if r:
        break
print("There is a positive number:",r)
									

Код (Pascal)

program Series10;
var
  check:Boolean;
  i,N,R:Integer;
begin
  Write('Введите N: ');
  Readln(N);
  check:=False;
  for i:=1 to N do
   begin
     Write('Введите ',i,' число: ');
     Readln(R);
     if R >0 then  check:=True;
   end;
  Writeln(check);
end.
									




Series. Абрамян
Series 1 Просмотров: 4664
Series 2 Просмотров: 2402
Series 3 Просмотров: 2189
Series 4 Просмотров: 2364
Series 5 Просмотров: 2238
Series 6 Просмотров: 2855
Series 7 Просмотров: 3066
Series 8 Просмотров: 3386
Series 9 Просмотров: 2059
Series 10 Просмотров: 2503
Series 11 Просмотров: 1898
Series 12 Просмотров: 2272
Series 13 Просмотров: 1667
Series 14 Просмотров: 1578
Series 15 Просмотров: 1889
Series 16 Просмотров: 2290
Series 17 Просмотров: 2088
Series 18 Просмотров: 2934
Series 19 Просмотров: 2631
Series 20 Просмотров: 1668
Series 21 Просмотров: 1816
Series 22 Просмотров: 1803
Series 23 Просмотров: 2245
Series 24 Просмотров: 2022
Series 25 Просмотров: 1558
Series 26 Просмотров: 1416
Series 27 Просмотров: 1325
Series 28 Просмотров: 1279
Series 29 Просмотров: 1302
Series 30 Просмотров: 1336
Series 31 Просмотров: 1316
Series 32 Просмотров: 1854
Series 33 Просмотров: 1099
Series 34 Просмотров: 1150
Series 35 Просмотров: 1531
Series 36 Просмотров: 1628
Series 37 Просмотров: 1060
Series 38 Просмотров: 1385
Series 39 Просмотров: 996
Series 40 Просмотров: 1373

Комментарии

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



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