
Листинг dll библиотеки
#include "pch.h"
#include<cmath>;
#include "SomeProjectDLL.h"
#include <string>
namespace SomeProjectDLL {
using namespace System::Windows::Forms;
using namespace System::Data::OleDb;
void Class1::Lab_tree(double a, double b, double h1, double c, double d, double h2, double& f, double& h, DataGridView^ dgv1)
{
SomeProjectDLL::Class1::CIKLICH(a, b, h1, c, d, h2, dgv1, h);
f = ceil(((b - a) / h1 + 1) * ((d - c) / h2 + 1));
}
void Class1::CIKLICH(double a, double b, double h1, double c, double d, double h2, DataGridView^dgv3, double& h)
{
double s, g, x = a, y = c, z;
s = Convert::ToInt32(ceil((d - c) / h2 + 1));
g = Convert::ToInt32(ceil((b - a) / h1 + 1));
int i, j;
for (i = 1; i <= g; i++)
{
for (j = 1; j <= s; j++)
{
z = SomeProjectDLL::Class1::funct(x, y);
SomeProjectDLL::Class1::VivodDataGrid3(dgv3,x, y, z);
if (h < z)
{
h = z;
}
y += h2;
}
x += h1;
}
}
double Class1::funct(double x, double y)
{
double z = y + exp(-x) + 2.8 * pow(x, 2) - x;
return z;
}
double Class1::Vvod(TextBox^ t)// Указатель на класс ТекстБокс
{
return Convert::ToDouble(t->Text);//В скобках входной и выходной поток информации
}
void Class1::Vivod(double x, TextBox^ t)
{
t->Text = Convert::ToString(x);
}
void Class1::VivodList(ListBox^ L, double n1, double s1)
{
L->Items->Add(n1.ToString() + " " + s1.ToString());
}
void Class1::VivodDataGrid3(DataGridView^ L, double n1, double s1, double s2)
{
L->Rows->Add(n1.ToString(), s1.ToString(), s2.ToString());
}
void Class1::outputmas(int* a, int len, DataGridView^ dgv1) {
dgv1->ColumnCount = len;
dgv1->RowCount = 2;
for (int i = 0; i < len; i++) {
dgv1->Rows[0]->Cells[i]->Value = "[" + i + "]";
dgv1->Rows[1]->Cells[i]->Value = a[i];
}
int width = 0;
for (int s = 0; s < dgv1->ColumnCount; s++) {
width += dgv1->Columns[s]->Width;
if (width > 410)
{
dgv1->Width = 410;
}
else
{
dgv1->Width = width;
}
}
}
void Class1::kiks(int* a, int len,TextBox^s, TextBox^ k, TextBox^ d, TextBox^ n) {
int i = 0;
int CH = 1, NCH = 1, countCH = 0, countNCH = 0;
for (i=0;i<len;i++)
{
if (a[i] % 2 == 1)
{
countNCH++;
NCH *= a[i];
}
else {
countCH++;
CH *= a[i];
}
}
for (i=0;i<len;i++)
{
if (abs(a[i])== 1)
{
countNCH++;
NCH *= a[i];
}
else {
countCH++;
CH *= a[i];
}
}
abs(NCH);
abs(CH);
if (NCH > CH) {
for(i=0;i<len;i++)
{
if (a[i] % 2 != 1)
{
a[i] = CH;
}
}
}
else
{
for (i = 0; i < len; i++)
{
if (a[i] % 2 == 1)
{
a[i] = NCH;
}
}
}
SomeProjectDLL::Class1::Vivod(CH, s);
SomeProjectDLL::Class1::Vivod(NCH, k);
SomeProjectDLL::Class1::Vivod(countCH, d);
SomeProjectDLL::Class1::Vivod(countNCH, n);
}
void Class1::VSTAVKA(int k, int* mas, int n, int m) {
int i;
for (i = n; i > (k+1) ; i--) {
mas[i + 1] = mas[i];
}
mas[k + 1] = m;
n++;
}
void Class1::PROSOYVSTAVKA( int* mas, int n){
int x,j;
for (int i = 2; i < n; i++) {
x = mas[i];
mas[0]=x;
j = i - 1;
while (x < mas[j]) {
mas[j + 1] = mas[j];
j = j - 1;
}
mas[j + 1] = x;
}
void Class1::add(void) {
ADOX::Catalog^ k = gcnew ADOX::CatalogClass();
try
{
k->Create("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + Application::StartupPath +"\\Databasesssss.mdb");
MessageBox::Show("База данных успешно создана", "База данных");
}
catch (System::Runtime::InteropServices::COMException ^ situation)
{
MessageBox::Show(situation->Message);
}
finally
{
k = nullptr;
}
}
void Class1::add_struct(void)
{
auto p = gcnew OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" + Application::StartupPath +"\\Databasesssss.mdb");
p->Open();
auto c = gcnew OleDbCommand("CREATE TABLE [Labaratory6] (Nomber_element counter,ishod_mass char(200),vstavka_mass char(200),sort_vstavkoy char(200))",p);
try {
c->ExecuteNonQuery();
MessageBox::Show("База данных успешно создана", "База данных");
}
catch (System::Runtime::InteropServices::COMException ^ situation) {
MessageBox::Show(situation->Message);
}
p->Close();
}
void Class1::add_zap(int* mass, int* rezmas, int* rezmas1, int len) {
for (int i = 0; i < len; i++) {
auto p = gcnew OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" + Application::StartupPath +"\\Databasesssss.mdb");
p->Open();
auto c = gcnew OleDbCommand("INSERT INTO [Labaratory6](" + "[ishod_mass],[vstavka_mass],[sort_vstavkoy])VALUES('" + mass[i] + "','" + rezmas[i] + "','" + rezmas1[i] + "')");
c->Connection = p;
c->ExecuteNonQuery();
p->Close();
}
MessageBox::Show("", "База данных");
}
}