MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Infokommunikatsiya injiniringgi
1-bosqich 432-22-guruh talabasi
Raxmatov Dilshodning
Dasturlash II
fanidan bajargan
mustaqil ishi
Topshirdi: Raxmatov Dilshod
Tekshirdi: Ibragimova Komila
1. #include
#include
#include
#include
using namespace System;
using namespace System::Windows::Forms;
int calculatePositiveSum(int** array, int N, int M) {
int sum = 0;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
if (array[i][j] > 0) {
sum += array[i][j];
}
}
}
return sum;
}
void fillArrayWithRandomNumbers(int** array, int N, int M) {
std::random_device rd;
std::mt19937 generator(rd());
std::uniform_int_distribution distribution(-1000, 100);
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
array[i][j] = distribution(generator);
}
}
}
[STAThread]
void main(array^ args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
int N, M;
TextBox^ textBoxN = gcnew TextBox();
textBoxN->Location = Point(10, 10);
Label^ labelN = gcnew Label();
labelN->Location = Point(10, 35);
labelN->Text = "Enter the value of N:";
Button^ buttonN = gcnew Button();
buttonN->Location = Point(180, 10);
buttonN->Text = "Submit";
buttonN->Click += gcnew EventHandler([&N, textBoxN](Object^ sender, EventArgs^ e) {
N = Convert::ToInt32(textBoxN->Text);
});
TextBox^ textBoxM = gcnew TextBox();
textBoxM->Location = Point(10, 60);
Label^ labelM = gcnew Label();
labelM->Location = Point(10, 85);
labelM->Text = "Enter the value of M:";
Button^ buttonM = gcnew Button();
buttonM->Location = Point(180, 60);
buttonM->Text = "Submit";
buttonM->Click += gcnew EventHandler([&M, textBoxM](Object^ sender, EventArgs^ e) {
M = Convert::ToInt32(textBoxM->Text);
});
Form^ form = gcnew Form();
form->Size = Drawing::Size(400, 300);
form->Controls->Add(textBoxN);
form->Controls->Add(labelN);
form->Controls->Add(buttonN);
form->Controls->Add(textBoxM);
form->Controls->Add(labelM);
form->Controls->Add(buttonM);
Application::Run(form);
int** array = new int*[N];
for (int i = 0; i < N; ++i) {
array[i] = new int[M];
}
fillArrayWithRandomNumbers(array, N, M);
DataGridView^ dataGridView = gcnew DataGridView();
dataGridView->Size = Drawing::Size(300, 200);
dataGridView->ColumnCount = M;
Visual studio 2012 yo’qligi va 2022 .NET frameworkida ishlagani sababli natijani chiqarishni iloji bo’lmadi.
2. #include
#include
#include
Do'stlaringiz bilan baham: |