ПППП (УКПО) / Домашняя работа / ДЗ2-3 Сложность / Программы-35 / Вариант_12
.docЗадача 1.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Вывод значения аргумента и значения функции";
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Black;
double x,
y;
char repeat;
do
{
Console.Clear();
Console.WriteLine("Введите значение аргумента x");
x = double.Parse(Console.ReadLine());e
if (x < -2) Console.WriteLine("Значение аргумента = " + x + "\nЗначение функции = " + '2');
if (x >= -2 && x < -1) Console.WriteLine("Значение аргумента = " + x + "\nЗначение функции = " + '1');
if (x >= -1 && x <= 0) Console.WriteLine("Значение аргумента = " + x + "\nЗначение функции = " + '0');
if (x > 0 && x < 1) Console.WriteLine("Значение аргумента = " + x + "\nЗначение функции = " + x);
if (x >= 1) Console.WriteLine("Значение аргумента = " + x + "\nЗначение функции = " + '1');
Console.WriteLine("Для повтора программы нажмите Y");
repeat=char.Parse(Console.ReadLine()); }
while (repeat == 'Y' || repeat == 'y');
}
}
}
Задача 2.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication
{
class Program
{
public static void Main(string[] args)
{ double [,] b;
int m, n;
char r;
do{
try{
Console.WriteLine("Введите целочисленное значение параметра m ");
m = int.Parse(Console.ReadLine());
Console.WriteLine("Введите целочисленное значение параметра n ");
n = int.Parse(Console.ReadLine());
}
catch{Console.WriteLine("Исходные данные введены неверно,нужно вводить целые положительные числа.");
}
b = new double[m, n];
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
FunBanana.Заполнение(b,m,n);
FunBanana.Печать(b,m,n);
FunBanana.Копирование (out ArrayList a);
FunBanana.Печать2(a);
Console.ReadLine();
Console.WriteLine("Завершить программу? Y/N");
r= char.Parse(Console.ReadLine());
} while (r=='Y'|| r=='y');
}
}
}
Задача 3.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public class Mymetod
{
public static double[,] Массив (out double[,] massiv, int n, int m)
{
Random gen = new Random();
massiv = new double[n, m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
massiv[i, j] = Math.Round(gen.NextDouble()*(21.7+12.4)-12.4, 2);
}
}
return massiv;
}
public static double[,] Вывод(double[,] massiv, int n, int m)
{
for (int i = 0; i < n; i++,Console.WriteLine())
{
for (int j = 0; j < m; j++)
{
Console.Write("{0,8}",massiv[i,j]);
}
}
return massiv;
}
public static double[] Одномерный(double[] massic)
{
for (int i = 0; i < massic.Length; i++)
Console.WriteLine("Конечный массив {0}",massic[i]);
return massic;
}
public bool IsOtr(double N)
{
bool b=false;
for(int i=0;i<N;i++)
if(N>0)
b=false;
else
b=true;
return b;
}
public double [] Копир(double[,] massiv, int n, int m, int k)
{
k=n*m;
double[]novi=new double[k];
int f = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (IsOtr(massiv[i, j]))
{ f++;
novi[i] = f;
}
}
} return novi;
}
}
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Magenta;
Console.Clear();
DateTime time = DateTime.Now;
ConsoleKeyInfo rep;
do{
double[,] massiv;
int N = 0;
Mymetod met = new Mymetod();
Console.WriteLine("{0:F}",time);
Console.WriteLine("Вас приветствует программа ");
Console.Write("Введите кол-во строк массив= ");
int n = int.Parse(Console.ReadLine());
Console.Write("Введите кол-во столбцов массива= ");
int m = int.Parse(Console.ReadLine());
int k = n * m;
massiv = new double[n, m];
double[]massic=new double[k];
Mymetod.Массив(out massiv, n, m);
Mymetod.Вывод(massiv, n, m);
met.IsOtr(N);
met.Копир(massiv, n, m, k);
Mymetod.Одномерный(massic);
Console.WriteLine("я не знаю почему он выдает такую ерунду(");
Console.WriteLine("Для выхода из программы нажмите Escape.Для продолжения нажмите любую клавишу");
rep = Console.ReadKey();
}while(rep.Key!=ConsoleKey.Escape);
}
}
}