Ответ:
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
using std::cout;
int main()
{
std::vector<int> ints = { 1 , -2, -3, -4, 5, 6, -7, -8, -9, 10 };
cout << "vector before transformation: ";
for (auto integer : ints) {
cout << integer << " ";
}
cout << std::endl;
for (std::size_t i = 1; i < ints.size(); ) {
if (ints[i] < 0) {
ints.erase(ints.begin() + i);
i += 1;
continue;
}
i += 2;
}
cout << "vector after transformation: ";
for (auto integer : ints) {
cout << integer << " ";
}
cout << std::endl;
}
Объяснение:
По условию создаем вектор, удаляем элементы из вектора, если число ниже 0, движемся через один элемент по вектору ¯\_(ツ)_/¯
С помощью компьютерных программ можно набирать текст, изменять его не
переписывая, сохранить его в памяти компьютера для хранения,
отпечатать на принтере копии без повторного ввода и отправить этот
текст с помощью электронной почты на другие компьютеры.
var
B: array [1..14] of Real;
i: Integer;
s: Real;
begin
Randomize;
WriteLn ('Mассив:');
for i := Low (B) to High (B) do begin
B [i] := Random (100) - 50;
Write (B [i]:5:2, ' ');
end;
s := 0;
for i := Low (B) to High (B) do begin
if B [i] > 0 then
s := s + B [i];
end;
WriteLn;
WriteLn ('Сумма положительных элементов массива = ', s:5:2);
end.
//Язык Pascal
Program Test;
Var str: string;
Begin
Write('Введите строку: ');
Readln(str);
str[2] := 'Ж';
str[length(str) - 1] := 'Ж';
Writeln();
Writeln('Строка после обработки: ', str);
End.
000 R = 0
001 R = 0
010 R = 1
011 R = 1
100 R = 0
101 R = 0
110 R = 0
111 R = 0
Код программы:
Var A,B,C : Boolean;
Begin
For A:=False to True do
For B:=False to True do
For C:=False to True do Writeln(Ord(A),Ord(B),Ord(C),' R = ',ord((not A) and (B or not C) and B));
end.