• Написать программу на С#, которая будет менять в заданном в программе массиве целых чисел все элементы, которые равны указанному значению, на противоположное значению по знаку.

Ответы 1

  • using System; using System.Collections.Generic; using System.Linq; using System.Text;using System.Threading.Tasks; namespace zamenaZnakaVmassive { class Program { static void Main(string[] args) { int[] mas = new int[10]; Random r = new Random(); Console.WriteLine("Исходный массив: "); for (int i = 0; i<mas.Length;i++) { mas[i] = r.Next(1, 10);Console.Write(mas[i] + " "); } Console.WriteLine(); Console.WriteLine("Введите значение"); int x = int.Parse(Console.ReadLine()); Console.WriteLine("Измененный массив: "); for (int i =0; i < mas.Length; i++) { if (mas[i] == x) mas[i] = mas[i] * (-1); Console.Write(mas[i] + " "); } Console.ReadKey(); { } } } }
    • Автор:

      dylanrwlj
    • 6 лет назад
    • 0
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years