М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации

Программирование 8 кл одна задача c++ Дан массив из n × m элементов. Найти индексы первого наименьшего
элемента массива.

👇
Ответ:
lenaguceva
lenaguceva
22.08.2020

#include <iostream>

using namespace std;

int main()

{

int n, m;

int **arr;

int min;

cout << "Enter dimension of array (n/m)" << endl;

cin >> n >> m;

arr = new int *[n];

for (int i = 0; i < n; i++) {

 arr[i] = new int[m];

}

for (int i = 0; i < n; i++) {

 for (int j = 0; j < m; j++) {

  cout << "arr[" << i << "][" << j << "] = ";

  cin >> arr[i][j];

 }

}

cout << "Your array:" << endl;

for (int i = 0; i < n; i++)

{

 for (int j = 0; j < m; j++)

 {

  cout << arr[i][j] << " ";

 }

 cout << endl;

}

cout << "Min is: ";

min = arr[0][0];

for (int i = 0; i < n; i++) {

 for (int j = 0; j < m; j++) {

  if (min > arr[i][j]) {

   min = arr[i][j];

  }

 }

}

cout << min << endl;

return 0;

}

4,8(97 оценок)
Открыть все ответы
Ответ:
lthyperdeath1
lthyperdeath1
22.08.2020

#include <iostream>

#include <vector>

using namespace std;

void ins_sort(vector<int>& vec) {

for (int i = 1; i < vec.size(); i++) {

 int j = i - 1;

 int flag = 0;

 int temp = vec[i];

 while (j >= 0 && vec[j] > temp) {

  vec[j + 1] = vec[j];

  j--;

  flag++;

 }

 vec[j + 1] = temp;

 if (flag != 0) {

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

   cout << vec[i] << " ";

  }

  cout << endl;

 }  

}  

}

signed main() {

int N;

cin >> N;

vector<int> vec(N);

for (int i = 0; i < N; i++)  

 cin >> vec[i];

ins_sort(vec);

return 0;

}

4,5(46 оценок)
Ответ:
Anna200689898098654
Anna200689898098654
22.08.2020

Движок не позволяет добавить архив с проектом

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApp3

{

   class Program

   {

       public class client

       {

           public string FIO;

           public string phone;

           public string adress;

           public client()

           {

           }

           public client(string FIO, string phone, string adress)

           {

               this.FIO = FIO;

               this.phone = phone;

               this.adress = adress;

           }

           public client(client NewClient)

           {

               this.FIO = NewClient.FIO;

               this.phone = NewClient.phone;

               this.adress = NewClient.adress;

           }

           public string PoluchitInfo()

           {

               return "ФИО: " + this.FIO + "\nтелефон: " + this.phone + "\nадрес: " + this.adress;

           }

       }

       public class customer: client

       {

           public double Trovar;

           public int Kolichestvo;

           public double Stoimost;

           public customer()

           {

           }

           public customer(customer NewCostumer)

           {

               this.FIO = NewCostumer.FIO;

               this.phone = NewCostumer.phone;

               this.adress = NewCostumer.adress;

               this.Trovar = NewCostumer.Trovar;

               this.Kolichestvo = NewCostumer.Kolichestvo;

               this.Stoimost = NewCostumer.Stoimost;

           }

           public customer(string FIO, string phone, string adress, double Trovar, int Kolichestvo)

           {

               this.FIO = FIO;

               this.phone = phone;

               this.adress = adress;

               this.Trovar = Trovar;

               this.Kolichestvo = Kolichestvo;

               this.SchitatStoimost();

           }

           public double SchitatStoimost()

           {

               return Stoimost = Trovar * Kolichestvo;

           }

       }

       static void Main(string[] args)

       {

           customer[] customers = new customer[3];

           customers[0] = new customer("Иванов", "322223322", "Бобруйск", 1.1, 2);

           customers[1] = new customer("Петров", "123456789", "Урюпинск", 2.2, 5);

           customers[2] = new customer("Сидоров", "987654321", "Крыжополь", 3.3, 10);

           double Sum = 0;

           foreach(customer Temp in customers)

           {

               Console.WriteLine(Temp.PoluchitInfo()+"\n");

               Sum += Temp.Stoimost;

           }

           Console.WriteLine(Sum.ToString());

           Console.ReadLine();

       }

   }

}

4,8(63 оценок)
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ