deadloxSasha
25.06.2020 15:39

Программирование итерационных алгоритмов. Приближенное значение функции y = f(x) должно быть вычислено с точностью e.


Программирование итерационных алгоритмов. Приближенное значение функции y = f(x) должно быть вычисле

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
Ашка1231
03.11.2021 16:01
// PascalABC.NET 3.0, сборка 1073
const
  sb='bcdfgjklmnpqrstvwxz';
  s='Computer programming is a process of computer programs creation';
var
  i,n:integer;
  s1,sn,t:string;
begin
  i:=1;
  while s[i]<>' ' do Inc(i);
  s1:=Copy(s,1,i-1);
  n:=Length(s); i:=n;
  while s[i]<>' ' do Dec(i);
  sn:=Copy(s,i+1,n-i);
  t:='';
  for i:=1 to Length(s1) do
    if Pos(s1[i],sb)>0 then t:=t+s1[i];
  s1:=t;
  t:='';
  for i:=1 to Length(sn) do
    if Pos(sn[i],sb)>0 then t:=t+sn[i];
  sn:=t;
  t:='';
  for i:=1 to Length(s1) do
    if Pos(s1[i],sn)>0 then
      if Pos(s1[i],t)=0 then t:=t+s1[i];
  for i:=1 to Length(t) do Write(t[i],' ');
  Writeln
end.
 
Тестовый прогон:
t r

2. "Нормальное" решение

// PascalABC.NET 3.0, сборка 1073
const
  sb='bcdfgjklmnpqrstvwxz';
  s='Computer programming is a process of computer programs creation';
begin
  var a:=s.ToWords(' ');
  a[0].Intersect(a[a.Length-1]).Where(x->Pos(x,sb)>0).Println(',')
end.

Тестовый прогон:
t,r
0,0(0 оценок)
Ответ:
DashaGaff
18.05.2021 15:06
#include <iostream>
#include <ctime>
int main()
{
    using namespace std;

    const int SIZE = 25;
    int massive[SIZE];

    //1й пункт
    cout << "Enter number: ";    
    int num;
    cin >> num;
    int s = 0;
    for (int i = 1; i <= num; i++)
        if (num % i == 0)
            if (i % 2 == 1)
                s = s + i;
    cout << "The sum of the odd divisors: " << s << endl;

    //2й пункт
    for (int i = 0; i < SIZE; i++)  
    {
        cout << "Enter #" << i + 1 << " element: ";
        cin >> massive[i];
    }
    for (int i = 0; i < SIZE; i++)
        if (massive[i] < 0)
        {
            massive[i] = 0;
            break;
        }
    for (int i = 0; i < SIZE; i++)
        cout << massive[i] << ' ';

    //3й пункт
    for (int i = 0; i < SIZE; i++)
        massive[i] = i + 1;
    for (int i = 0; i < SIZE; i++)
        if (massive[i] % 3 == 0)
            massive[i] *= massive[2];
    cout << endl;
    for (int i = 0; i < SIZE; i++)
        cout << massive[i] << ' ';

    //4й пункт
    srand(time(0));
    for (int i = 0; i < SIZE; i++)
        massive[i] = rand();
    cout << endl;
    for (int i = 0; i < SIZE; i++)
        cout << massive[i] << ' ';
    cout << endl;
    cout << "Enter number: ";
    int num2;
    cin >> num2;
    bool ifsum = false;
    for (int i = 0; i < SIZE - 1; i++)
        if (massive[i] + massive[i + 1] == num2)
        {
            ifsum = true;
            break;
        }
    if (ifsum)
        cout << "yes";
    else
        cout << "no";
    cout << endl;
    return 0;
}
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота