yaudo47
?>

Составьте программу для вычисления величины силы тока на участке электрической цепи с сопростивлением r ом при напряжении

Информатика

Ответы

sashakrotova943
Программа на скрине! Надеюсь
Составьте программу для вычисления величины силы тока на участке электрической цепи с сопростивление
tarhan1221

#include <iostream>

#include <vector>

#include <fstream>

using namespace std;

struct Word

{

   string word;

   int amount = 1;

};

int main()

{

   ifstream input;

   input.open("text.txt");

   vector<Word> words;

   while(!input.eof())

   {

       string str;

       getline(input, str);

       cout << str << "\n";

   }

   cout << "\n";

   input.close();

   input.open("text.txt");

   while(!input.eof())

   {

       Word word;

       input >> word.word;

       words.push_back(word);

   }

   input.close();

   string file;

   ofstream create(file);

   cout << "Input file name: ";

   cin >> file;

   cout << "\n";

   create << file;

   ofstream output(file);

   for(int i = 0; i < words.size() - 1; i++)

       for(int j = i + 1; j < words.size(); j ++)

           if(words[i].word == words[j].word && words[i].word != "NULL")

           {

               words[i].amount++;

               words[j] = {"NULL", -1};

           }

   for (int i = 0; i < words.size() - 1; i++)

       for (int j = 0; j < words.size() - 1; j++)

           if (words[j].amount < words[j + 1].amount)

               swap(words[j], words[j + 1]);

   for (int i = 0; i < words.size(); i++)

       if(words[i].amount > 1)

       {

           cout << words[i].word << " ";

           output << words[i].word << " ";

       }

   output.close();

   return 0;

}


Разработать программу на C++. В произвольном тексте (взятом из файла), содержащем не более 10 строк,
Eduard Popik

Программа:

Python:

otr, pr = 0, 1

n = int(input('n = '))

print('Введите числа массива: ')

arr = [int(input()) for i in range(n)]

print(arr)

for i in arr:

   if i < 0:  otr += i

   if arr.index(max(arr)) > arr.index(min(arr)):

       if arr.index(i) > arr.index(min(arr)) and arr.index(i) < arr.index(max(arr)):  

           pr *= i

   elif arr.index(max(arr)) < arr.index(min(arr)):

       if arr.index(i) < arr.index(min(arr)) and arr.index(i) > arr.index(max(arr)):  

           pr *= i

print('Сумма отрицательных чисел:', otr)

print('Произведение элементов между минимальным и максимальным числами:', pr)

arr.sort()

print('Отсортированный массив:', arr)

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Составьте программу для вычисления величины силы тока на участке электрической цепи с сопростивлением r ом при напряжении
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

kabinet17
Pervosha
rkorneev19061
sryzhova6392
Филиппович_Николаевич
Elen-ti81459
zibuxin6
Маринина_Елена
Irinalobanowa
natalia-shelkovich
Марина1101
Смирнов-Оськина
Ushakova Sakhno
milanparipovic864
yanva