|
C++ programmalastırıw tilinde dızbekler menen islew. Dızbeklerge programmalar tuzush. Joba
|
bet | 7/8 | Sana | 06.12.2023 | Hajmi | 285,94 Kb. | | #112387 |
Bog'liq massivcout << i << ", " << j << " = "; cin >> A[i][j];
}
}
for (i=1; i<=n; i++)
{
for (j=1; j<=n; j++) cout << A[i][j] << " "; cout << endl;
}
min=A[1][1]; max=A[1][1]; for (i=1; i<=n; i++)
{
for (j=1; j<=n; j++)
{
if (maxA[i][j]) min=A[i][j];
}
}
S=min + max; P=min*max; cout << "Massivning eng kichik elementi: min = " << min
<< "\n"; cout << "Massivning eng katta elementi: max = " << max <<
"\n"; cout << "Sum = " << S << "; P = " << P; return 0;
II Bap Dızbeklerningeng úlken hám eń kishi elementlerine tiyisli massalar
2. 1 Dızbeklerge tiyisli máseleler
1 Mısal :Bas dioganallardan tómende bolǵan elementlerden eń úlken hám eń kishi shıǵarıwshı programma tuzilsin.
Tómendegi obiektti keltiremiz.
#include
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{ int n; int a[40][40]; for (int i=1;i<=n;i++) for (int j=1;j<=n;j++)
a[i][j]=StrToInt(StringGrid1->Cells[i][j]); int min=a[1][1];int max=a[1][1]; for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) if (i<=j) {
if (min>a[i][j]) min=a[i][j]; if (maxMemo1->Lines->Add("min"+IntToStr(min)); Memo1->Lines->Add("max"+IntToStr(max)); for (int i=1;i<=min;i++)
if (min%i==0 && max%i==0) Memo1->Lines-
>Add(IntToStr(i));
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{ int n;
n=StrToInt(Edit1->Text );
StringGrid1->ColCount=n+1;
StringGrid1->RowCount=n+1;
}
Quyidagi natejani olamiz:
|
| |