Загрузка...

Help C problem, you can C++

Thread in C/C++ created by happycozero Oct 7, 2021. 326 views

  1. happycozero
    happycozero Topic starter Oct 7, 2021 Сад изящных слов 124 Apr 23, 2020
    Ребята, помогите сделать эти задачи

    2. Даны шесть целых ненулевых положительных чисел. Найти сумму трех наименьших чисел.

    4. В вещественном массиве хранится информация о количестве осадков, выпавших за каждый день месяца N(N - любой месяц в году).
    Определить, в какие числа месяца осадков не было.
     
  2. Daemon
    Daemon Oct 7, 2021 1680 Jan 8, 2021
    happycozero,
    Code
    #include <iostream>

    using namespace std;

    void main() {
    int mas[6];

    for (int i = 0; i < 6; i++)
    cin >> mas[i];

    for (int i = 0; i < 6; i++)
    for (int j = i + 1; j < 6; j++)
    if (mas[j] < mas[i])
    swap(mas[j], mas[i]);

    cout << "\n" << mas[0] + mas[1] + mas[2] << "\n";
    system("pause");
    }
    Code
    #include <iostream>

    using namespace std;

    void main() {
    double mas[30]; int c = 0;

    for (int i = 0; i < 30; i++) {
    cin >> mas[i];
    if (mas[i] == 0) c++;
    }

    cout << "\n" << c << "\n";
    system("pause");
    }
     
  3. Fender_inactive2697143
    C
    #include <bits/stdc++.h>

    int main() {
    std::array<unsigned, 6u> a{};
    for (auto& n : a) std::cin >> n;

    std::sort(a.begin(), a.end());
    std::cout << a.at(0u) + a.at(1u) + a.at(2u);
    }
     
Top
Loading...