У=124+8×<5
у=5-124>8×
у=-119>8×
Using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace СиШарп
{
class Program
{
static void Main(string[] args)
{
Console.Write("a = ");
double a = double.Parse(Console.ReadLine());
Console.Write("b = ");
double b = double.Parse(Console.ReadLine());
Console.Write("c = ");
double c = double.Parse(Console.ReadLine());
if (a > b) a = b;
if (a > c) a = c;
Console.WriteLine("Min = {0}",a);
Console.ReadKey();
}
}
}
#include <iostream>
using namespace std;
/*
* Сумма элементов массива
* [ 1, 2, 3] => 6
* [-5, 8, 2] => 5
*/
int arraySum(int a[], int s)
{
int ret = 0;
for (int i = 0; i < s; i++) {
ret += a[i];
}
return ret;
}
/*
* Определение, каких чисел больше в массиве.
* [-1, 2, 3] => "Положительных"
* [ 1, -2, -3] => "Отрицательных"
*/
const char* plusMinGreater(int a[], int s)
{
int plus = 0, minus = 0;
for (int i = 0; i < s; i++) {
if (a[i] > 0) plus++;
if (a[i] < 0) minus++;
}
return (plus > minus ?
"Положительных чисел больше" :
(plus < minus ?
"Отрицательных чисел больше" :
"Положителных и отрицательных поровну"));
}
/*
* Разница между максимальным и минимальным элементами.
* [5, 3, 2] => 5 - 2 = 3
*/
int maxMinDiff(int a[], int s)
{
int min = a[0], max = a[0];
for (int i = 1; i < s; i++) {
if (a[i] > max) max = a[i];
if (a[i] < min) min = a[i];
}
return max - min;
}
int main()
{
int n;
cout << "n = ";
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cout << "Число " << i << ": ";
cin >> a[i];
}
cout << plusMinGreater(a, n) << endl
<< "Сумма: " << arraySum(a, n) << endl
<< "Разница максимального и минимального элементов: "
<< maxMinDiff(a, n) << endl;
return 0;
}