1
0
This commit is contained in:
Debug_pro
2026-02-12 01:01:44 +03:00
commit 43d7845cf1
23 changed files with 1353 additions and 0 deletions

363
.gitignore vendored Normal file
View File

@@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

9
App.xaml Normal file
View File

@@ -0,0 +1,9 @@
<Application x:Class="Lab.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Lab"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

14
App.xaml.cs Normal file
View File

@@ -0,0 +1,14 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace Lab
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

42
ArrayReverseWindow.xaml Normal file
View File

@@ -0,0 +1,42 @@
<Window x:Class="Lab.ArrayReverseWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lab"
mc:Ignorable="d"
Title="ЛР3.1 - Инверсия массива" Height="450" Width="800">
<Grid Margin="14">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="0,0,0,10">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="ЛР3.1: Инвертировать массив"/>
<TextBlock TextWrapping="Wrap" Margin="0,6,0,0">
Введите элементы массива (числа) одной строкой. Разделители: пробел, запятая, ;.
Программа развернёт массив «на месте» (через обмен элементов).
</TextBlock>
</StackPanel>
<TextBlock Grid.Row="1" FontWeight="SemiBold" Text="Ввод массива:"/>
<TextBox Grid.Row="2" x:Name="ArrayInBox" Height="70" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>
<StackPanel Grid.Row="3" Orientation="Horizontal">
<Button Content="Инвертировать" Click="ClickReverse" MinWidth="140" MinHeight="30"/>
<Button Content="Очистить" Margin="10,0,0,0" Click="ClickClear" MinWidth="140" MinHeight="30"/>
<Button Content="Назад" Margin="10,0,0,0" Click="ClickBack" MinWidth="140" MinHeight="30"/>
</StackPanel>
<TextBlock Grid.Row="4" FontWeight="SemiBold" Text="Результат:"/>
<TextBox Grid.Row="5" x:Name="ArrayOutBox" TextWrapping="Wrap" IsReadOnly="True" VerticalScrollBarVisibility="Auto"/>
<TextBlock Grid.Row="6" x:Name="ArrayInfoText" Opacity="0.85" TextWrapping="Wrap"/>
</Grid>
</Window>

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Lab
{
/// <summary>
/// Interaction logic for ArrayReverseWindow.xaml
/// </summary>
public partial class ArrayReverseWindow : Window
{
private void ClickBack(object sender, RoutedEventArgs e) => Close();
private void ClickClear(object sender, RoutedEventArgs e)
{
ArrayInBox.Clear();
ArrayOutBox.Clear();
ArrayInfoText.Text = "";
}
private void ClickReverse(object sender, RoutedEventArgs e)
{
ArrayOutBox.Clear();
ArrayInfoText.Text = "";
if (!Parsers.TryParseDoubleArray(ArrayInBox.Text, out double[] vals, out string err))
{
ArrayInfoText.Text = err;
return;
}
for(int i=0,j=vals.Length-1;i<j;i++,j--)(vals[i],vals[j])=(vals[j],vals[i]);
ArrayOutBox.Text = string.Join(", ", vals);
ArrayInfoText.Text = $"Готово. Длина массива: {vals.Length}.";
}
public ArrayReverseWindow()
{
InitializeComponent();
}
}
}

10
AssemblyInfo.cs Normal file
View File

@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

53
ClassMultiplyWindow.xaml Normal file
View File

@@ -0,0 +1,53 @@
<Window x:Class="Lab.ClassMultiplyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lab"
mc:Ignorable="d"
Title="ЛР5.1 — Класс + multiply" Height="450" Width="800">
<Grid Margin="14">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="0,0,0,10">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="ЛР5.1: Класс (first/second) и метод multiply(double)"/>
<TextBlock TextWrapping="Wrap" Margin="0,6,0,0">
Объект описывает число first + second, где first — целая часть (int), а second — дробная часть (double) в диапазоне [0;1).
Метод multiply(double) возвращает новый объект, умноженный на заданное число.
</TextBlock>
</StackPanel>
<Grid Grid.Row="1" Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="first:" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" x:Name="FirstBox" Text="3"/>
<Label Grid.Row="1" Grid.Column="0" Content="second (0 ≤ second &lt; 1):" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" x:Name="SecondBox" Text="0.25"/>
<Label Grid.Row="2" Grid.Column="0" Content="k (множитель):" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="1" x:Name="KBox" Text="2"/>
</Grid>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<Button Content="Умножить" Click="ClickMul" MinWidth="140" MinHeight="30"/>
<Button Content="Назад" Margin="10,0,0,0" Click="ClickBack" MinWidth="140" MinHeight="30"/>
</StackPanel>
<TextBlock Grid.Row="3" Padding="10" x:Name="ClassOutText" TextWrapping="Wrap" />
</Grid>
</Window>

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Lab
{
/// <summary>
/// Interaction logic for ClassMultiplyWindow.xaml
/// </summary>
public partial class ClassMultiplyWindow : Window
{
private void ClickBack(object sender, RoutedEventArgs e) => Close();
private void ClickMul(object sender, RoutedEventArgs e)
{
ClassOutText.Text = "";
if (!Parsers.TryParseDouble(FirstBox.Text, out var first))
{
ClassOutText.Text = "first должен быть числом.";
return;
}
if (!Parsers.TryParseDouble(SecondBox.Text, out var second))
{
ClassOutText.Text = "second должен быть числом.";
return;
}
if (second < 0 || second >= 1)
{
ClassOutText.Text = "second должен быть в диапазоне [0; 1).";
return;
}
if (!Parsers.TryParseDouble(KBox.Text, out var k))
{
ClassOutText.Text = "k должен быть числом.";
return;
}
var num = new SplitNumber();
num.Value = first + second;
double val = num.Value;
first = num.first;
second = num.second;
num.Multiply(k);
ClassOutText.Text =
$"Исходное число: {val} (first={first}, second={second})\n" +
$"Множитель k = {k}\n" +
$"Результат: {num.Value} (first={num.first}, second={num.second})";
}
public ClassMultiplyWindow()
{
InitializeComponent();
}
}
}

43
FibonacciWindow.xaml Normal file
View File

@@ -0,0 +1,43 @@
<Window x:Class="Lab.FibonacciWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lab"
mc:Ignorable="d"
Title="ЛР2.2 - Фибоначчи" Height="450" Width="800">
<Grid Margin="14">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="0,0,0,10">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="ЛР2.2: Числа Фибоначчи меньше N"/>
<TextBlock TextWrapping="Wrap" Margin="0,6,0,0">
Введите целое N (N &gt; 0). Программа выведет все числа Фибоначчи, строго меньшие N.
</TextBlock>
</StackPanel>
<Grid Grid.Row="1" Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="N:" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" x:Name="NBox"/>
</Grid>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<Button Content="Посчитать" Click="ClickCalc" MinWidth="140" MinHeight="30"/>
<Button Content="Назад" Margin="10,0,0,0" Click="ClickBack" MinWidth="140" MinHeight="30"/>
</StackPanel>
<TextBox Grid.Row="3" x:Name="OutBox" TextWrapping="Wrap" IsReadOnly="True" VerticalScrollBarVisibility="Auto" Margin="0,10,0,10" />
<TextBlock Grid.Row="4" x:Name="InfoText" Opacity="0.85" TextWrapping="Wrap" />
</Grid>
</Window>

49
FibonacciWindow.xaml.cs Normal file
View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Lab
{
/// <summary>
/// Interaction logic for FibonacciWindow.xaml
/// </summary>
public partial class FibonacciWindow : Window
{
private void ClickBack(object sender, RoutedEventArgs e) => Close();
private void ClickCalc(object sender, RoutedEventArgs e)
{
OutBox.Text = "";
InfoText.Text = "";
if (!Parsers.TryParseInt(NBox.Text, out int n) || n <= 0) {
InfoText.Text = "Введите целое N, N > 0.";
return;
}
long a = 1;
long b = 1;
List<long> list = new List<long>();
while (a < n) { list.Add(a); long next = a + b; a = b; b = next; }
OutBox.Text = string.Join(", ", list);
InfoText.Text = $"Найдено чисел: {list.Count}.";
}
public FibonacciWindow()
{
InitializeComponent();
}
}
}

11
Lab.csproj Normal file
View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

25
Lab.sln Normal file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36429.23 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab", "Lab.csproj", "{35D80504-6D3F-4843-90A9-9318DC835884}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{35D80504-6D3F-4843-90A9-9318DC835884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35D80504-6D3F-4843-90A9-9318DC835884}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35D80504-6D3F-4843-90A9-9318DC835884}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35D80504-6D3F-4843-90A9-9318DC835884}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {83E5F320-DB1F-40AC-A37B-B87C8CB95B48}
EndGlobalSection
EndGlobal

41
MainWindow.xaml Normal file
View File

@@ -0,0 +1,41 @@
<Window x:Class="Lab.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lab"
mc:Ignorable="d"
Title="Ну очень крутая 6 лаба" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Grid.Row="0">
<TextBlock FontSize="20" FontWeight="Bold">
Лабораторная работа №6
</TextBlock>
<TextBlock FontSize="14" FontStyle="Italic">
Пресняков Илья Сергеевич
</TextBlock>
</StackPanel>
<Grid Margin="20" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Content="ЛР2.1: Треугольник" Margin="5" Grid.Row="0" Grid.Column="0" Click="ClickOpenTriangleWindow" />
<Button Content="ЛР2.2: Фибоначчи &lt; N" Margin="5" Grid.Row="1" Grid.Column="0" Click="ClickOpenFibonacciWindow" />
<Button Content="ЛР3.1: Инверсия массива" Margin="5" Grid.Row="2" Grid.Column="0" Click="ClickOpenArrayReverseWindow" />
<Button Content="ЛР3.2: Матрица 11×11" Margin="5" Grid.Row="0" Grid.Column="1" Click="ClickOpenMatrixCompareWindow" />
<Button Content="ЛР4.3: Отражение матрицы" Margin="5" Grid.Row="1" Grid.Column="1" Click="ClickOpenMatrixFlipWindow" />
<Button Content="ЛР5.1: Класс + multiply(double)" Margin="5" Grid.Row="2" Grid.Column="1" Click="ClickOpenClassMultiplyWindow" />
</Grid>
</Grid>
</Window>

39
MainWindow.xaml.cs Normal file
View File

@@ -0,0 +1,39 @@
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Lab
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private void ClickOpenTriangleWindow (object sender, RoutedEventArgs e) => Open( new TriangleWindow() );
private void ClickOpenFibonacciWindow (object sender, RoutedEventArgs e) => Open( new FibonacciWindow() );
private void ClickOpenArrayReverseWindow (object sender, RoutedEventArgs e) => Open( new ArrayReverseWindow() );
private void ClickOpenMatrixCompareWindow (object sender, RoutedEventArgs e) => Open( new MatrixCompareWindow() );
private void ClickOpenMatrixFlipWindow (object sender, RoutedEventArgs e) => Open( new MatrixFlipWindow() );
private void ClickOpenClassMultiplyWindow (object sender, RoutedEventArgs e) => Open( new ClassMultiplyWindow() );
public MainWindow()
{
InitializeComponent();
}
private void Open(Window w)
{
w.Owner = this;
w.Closed += (_, _) => Show();
Hide();
w.Show();
}
}
}

106
Matrices.cs Normal file
View File

@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab
{
internal class Matrices
{
public static DataTable CreateMatrix(int rows, int cols, string prefix)
{
DataTable dt = new DataTable();
for (int col = 0; col < cols; col++)
{
dt.Columns.Add($"{prefix}{col + 1}", typeof(double));
}
for (int row = 0; row < rows; row++)
{
DataRow dr = dt.NewRow();
for (int col = 0; col < cols; col++)
{
dr[col] = 0;
}
dt.Rows.Add(dr);
}
return dt;
}
public static DataTable CreateMatrixInts(int rows, int cols, string prefix)
{
DataTable dt = new DataTable();
for (int col = 0; col < cols; col++)
{
dt.Columns.Add($"{prefix}{col + 1}", typeof(int));
}
for (int row = 0; row < rows; row++)
{
DataRow dr = dt.NewRow();
for (int col = 0; col < cols; col++)
{
dr[col] = 0;
}
dt.Rows.Add(dr);
}
return dt;
}
public static void RandomFill(DataTable dt, int minIncl, int maxIncl)
{
Random rng = new Random();
for (int row = 0; row < dt.Rows.Count; row++)
{
for (int col = 0; col < dt.Columns.Count; col++)
{
dt.Rows[row][col] = (double)rng.Next(minIncl, maxIncl + 1);
}
}
}
public static int[,] ToArray(DataTable dt)
{
int rows = dt.Rows.Count;
int cols = dt.Columns.Count;
var array = new int[rows, cols];
for (int row =0; row < rows; row++)
{
for (int col = 0; col < cols; col++)
{
array[row, col] = Convert.ToInt32(dt.Rows[row][col]);
}
}
return array;
}
public static DataTable FromArray(int[,] array, string prefix)
{
int rows = array.GetLength(0);
int cols = array.GetLength(1);
var dt = CreateMatrix(rows, cols, prefix);
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < cols; col++)
{
dt.Rows[row][col] = array[row, col];
}
}
return dt;
}
}
}

42
MatrixCompareWindow.xaml Normal file
View File

@@ -0,0 +1,42 @@
<Window x:Class="Lab.MatrixCompareWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lab"
mc:Ignorable="d"
Title="ЛР3.2 - Матрица 11x11" Height="450" Width="800">
<Grid Margin="14">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="0,0,0,10">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="ЛР3.2: Матрица 11x11 -> матрица 0/1"/>
<TextBlock TextWrapping="Wrap" Margin="0,6,0,0">
Дана матрица A размера 11x11. Построить матрицу B того же размера, где
B[i,j]=1, если A[i,j] строго больше диагонального элемента A[i,i] в своей строке, иначе 0.
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Button Content="Сгенерировать A (-25..25)" Click="ClickGen" MinWidth="140" MinHeight="30"/>
<Button Content="Построить B" Margin="10,0,0,0" Click="ClickBuild" MinWidth="140" MinHeight="30"/>
<Button Content="Назад" Margin="10,0,0,0" Click="ClickBack" MinWidth="140" MinHeight="30"/>
</StackPanel>
<TextBlock Grid.Row="2" FontWeight="SemiBold" Text="Матрица A (11x11):"/>
<DataGrid Grid.Row="3" x:Name="GridA" />
<TextBlock Grid.Row="4" FontWeight="SemiBold" Text="Матрица B (0/1):"/>
<DataGrid Grid.Row="5" x:Name="GridB" />
<TextBlock Grid.Row="6" x:Name="MatrixInfoText" Opacity="0.85" TextWrapping="Wrap"/>
</Grid>
</Window>

View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Lab
{
/// <summary>
/// Interaction logic for MatrixCompareWindow.xaml
/// </summary>
public partial class MatrixCompareWindow : Window
{
private DataTable _a = Matrices.CreateMatrix(11, 11, "A");
private DataTable _b = Matrices.CreateMatrixInts(11, 11, "B");
private void ClickBack(object sender, RoutedEventArgs e) => Close();
private void ClickGen(object sender, RoutedEventArgs e)
{
Matrices.RandomFill(_a, -25, 25);
MatrixInfoText.Text = "Матрица A сгенерирована.";
}
private void ClickBuild(object sender, RoutedEventArgs e)
{
var a = Matrices.ToArray(_a);
var b = new int[11, 11];
for (int row = 0; row < 11; row++)
{
int diag = a[row, row];
for (int col = 0; col < 11; col++)
{
b[row, col] = a[row, col] > diag ? 1 : 0;
}
}
_b = Matrices.FromArray(b, "B");
GridB.ItemsSource = _b.DefaultView;
MatrixInfoText.Text = "Матрица B построена.";
}
public MatrixCompareWindow()
{
InitializeComponent();
GridA.ItemsSource = _a.DefaultView;
GridB.ItemsSource = _b.DefaultView;
}
}
}

43
MatrixFlipWindow.xaml Normal file
View File

@@ -0,0 +1,43 @@
<Window x:Class="Lab.MatrixFlipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lab"
mc:Ignorable="d"
Title="ЛР4.3 - Отражение матрицы" Height="450" Width="800">
<ScrollViewer Margin="14" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock FontSize="18" FontWeight="SemiBold" Text="ЛР4.3: Отражение матрицы по горизонтальной оси"/>
<TextBlock TextWrapping="Wrap" Margin="0,6,0,12">
Создайте неквадратную матрицу размером R×C (динамически), заполненную целыми числами 0..100.
Затем отразите её относительно центральной горизонтальной оси (переверните строки: первая - последняя, и т.д.).
</TextBlock>
<WrapPanel>
<StackPanel Margin="0,0,16,0">
<TextBlock FontWeight="SemiBold" Text="R (строки):"/>
<TextBox x:Name="RowsBox" Text="5"/>
</StackPanel>
<StackPanel Margin="0,0,16,0">
<TextBlock FontWeight="SemiBold" Text="C (столбцы):"/>
<TextBox x:Name="ColsBox" Text="7"/>
</StackPanel>
</WrapPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Button Content="Создать и заполнить (0..100)" Click="ClickCreate" MinWidth="140" MinHeight="30"/>
<Button Content="Отразить" Margin="10,0,0,0" Click="ClickFlip" MinWidth="140" MinHeight="30"/>
<Button Content="Назад" Margin="10,0,0,0" Click="ClickBack" MinWidth="140" MinHeight="30"/>
</StackPanel>
<TextBlock FontWeight="SemiBold" Text="Исходная матрица:"/>
<DataGrid x:Name="GridSrc" Height="220"/>
<TextBlock FontWeight="SemiBold" Text="Отражённая матрица:"/>
<DataGrid x:Name="GridDst" Height="220"/>
<TextBlock x:Name="FlipInfoText" Opacity="0.85" TextWrapping="Wrap"/>
</StackPanel>
</ScrollViewer>
</Window>

94
MatrixFlipWindow.xaml.cs Normal file
View File

@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Lab
{
/// <summary>
/// Interaction logic for MatrixFlipWindow.xaml
/// </summary>
public partial class MatrixFlipWindow : Window
{
private DataTable? _src;
private DataTable? _dst;
private void ClickBack(object sender, RoutedEventArgs e) => Close();
private bool TryGetSize(out int rows, out int cols)
{
rows = 0;
cols = 0;
if (!Parsers.TryParseInt(RowsBox.Text, out rows) || !Parsers.TryParseInt(ColsBox.Text, out cols)) {
FlipInfoText.Text = "Размеры должны быть целыми числами.";
return false;
}
if (rows < 1 || cols < 1)
{
FlipInfoText.Text = "Размеры должны быть больше 1";
return false;
}
return true;
}
private void ClickCreate(object sender, RoutedEventArgs e)
{
if (!TryGetSize(out int rows, out int cols)) return;
_src = Matrices.CreateMatrixInts(rows, cols, "A");
Matrices.RandomFill(_src, 0, 100);
GridSrc.ItemsSource = _src.DefaultView;
_dst = Matrices.CreateMatrixInts(rows, cols, "B");
GridDst.ItemsSource = _dst.DefaultView;
FlipInfoText.Text = $"Создана матрица {rows}×{cols}, заполнена числами 0..100.";
}
private void ClickFlip(object sender, RoutedEventArgs e)
{
if (_src is null)
{
FlipInfoText.Text = "Сначала создайте матрицу.";
return;
}
var a = Matrices.ToArray(_src);
int rows = a.GetLength(0);
int cols = a.GetLength(1);
var b = new int[rows, cols];
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < cols; col++)
{
b[rows - 1 - row, col] = a[row, col];
}
}
_dst = Matrices.FromArray(b, "B");
GridDst.ItemsSource = _dst.DefaultView;
FlipInfoText.Text = "Готово: строки перевёрнуты (отражение по горизонтальной оси).";
}
public MatrixFlipWindow()
{
InitializeComponent();
}
}
}

44
Parsers.cs Normal file
View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab
{
internal class Parsers
{
public static bool TryParseDouble(string? s, out double val) => double.TryParse((s ?? "").Trim().Replace(",", "."), out val);
public static bool TryParseInt(string? s, out int val) => int.TryParse((s ?? "").Trim(), out val);
public static bool TryParseDoubleArray(string? s, out double[] vals, out string err)
{
vals = Array.Empty<double>();
err = "";
if (string.IsNullOrEmpty(s) || string.IsNullOrEmpty(s)) {
err = "Пустой ввод. Введите числа, разделяя их пробелами/запятыми/точкой с запятой.";
return false;
}
string[] parts = s.Split(new[] { ' ', '\t', '\n', '\r', ',', ';' });
List<double> list = new List<double>();
for (int i = 0; i < parts.Length; i++)
{
if (!TryParseDouble(parts[i], out double val))
{
err = $"Вронгаешь элемент! [ #{i + 1}: «{parts[i]}» ]";
return false;
}
list.Add(val);
}
vals = list.ToArray();
return true;
}
}
}

37
SplitNumber.cs Normal file
View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab
{
internal class SplitNumber
{
public double first { get; private set; }
public double second { get; private set; }
public double Value
{
get { return first + second; }
set
{
first = Math.Truncate(value);
second = Math.Abs(value - first);
second = Math.Round(second, 10);
if (second >= 1)
{
first += 1;
second = 0;
}
}
}
public void Multiply(double m)
{
Value = Value * m;
}
}
}

49
TriangleWindow.xaml Normal file
View File

@@ -0,0 +1,49 @@
<Window x:Class="Lab.TriangleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lab"
mc:Ignorable="d"
Title="ЛР2.1 - Треугольник" Height="450" Width="800">
<Grid Margin="14">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="0,0,0,10">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="ЛР2.1: Проверка существования треугольника"/>
<TextBlock TextWrapping="Wrap" Margin="0,6,0,0">
Даны положительные действительные x, y, z. Проверить, существует ли треугольник со сторонами x, y, z.
Условие: сумма любых двух сторон строго больше третьей.
</TextBlock>
</StackPanel>
<Grid Grid.Row="1" Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="x:" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" x:Name="XBox"/>
<Label Grid.Row="1" Grid.Column="0" Content="y:" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" x:Name="YBox"/>
<Label Grid.Row="2" Grid.Column="0" Content="z:" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="1" x:Name="ZBox"/>
</Grid>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<Button Content="Проверить" Click="ClickCheck" MinWidth="140" MinHeight="30"/>
<Button Content="Назад" Click="ClickBack" MinWidth="140" MinHeight="30" Padding="1,1,1,1" Margin="10,0,0,0"/>
</StackPanel>
<TextBlock Grid.Row="3" x:Name="ResultText" TextWrapping="Wrap" />
</Grid>
</Window>

53
TriangleWindow.xaml.cs Normal file
View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Lab
{
/// <summary>
/// Interaction logic for TriangleWindow.xaml
/// </summary>
public partial class TriangleWindow : Window
{
private void ClickCheck(object sender, RoutedEventArgs e) {
if (!Parsers.TryParseDouble(XBox.Text, out double x) ||
!Parsers.TryParseDouble(YBox.Text, out double y) ||
!Parsers.TryParseDouble(ZBox.Text, out double z))
{
ResultText.Text = "Введите три положительных числа (например: 2.5).";
return;
}
if (x <=0 ||
y <=0 ||
z <=0)
{
ResultText.Text = "Стороны должны быть строго положительными.";
return;
}
bool check = x + y > z && x + z > y && y + z > x;
ResultText.Text = check ? "Треугольник существует." :
"Треугольник не существует.";
}
private void ClickBack(object sender, RoutedEventArgs e) => Close();
public TriangleWindow()
{
InitializeComponent();
}
}
}