Mavzu: Funksiya va massivlar. Misol
Download 0.58 Mb.
|
Shomirzayev Abdujalil Dasturlash asoslari.
Mavzu: Funksiya va massivlar. Misol: Berilgan n x m o‘lchamdagi matrisaning k - ustundagi eng katta elementi topilsin . Dastur kodi: #include using namespace std; int K_ustun_max(int n,int k,int **a) { int max=a[0][k]; for(int i=1;i return max; } int main() { int n, m, k, l; int **a; cout << "Matritsaning satrlar soni="; cin >> n; cout << "Matritsaning ustunlar soni="; cin >> m; // matritsani hosil qilish a = new int *[n]; for (int i = 0; i < n; i++) a[i] = new int[m]; srand(time(0)); // matritsa elementlari qiymatlarini tanlab olish for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) a[i][j] = rand() % 90 + 10; // matritsani chop etish cout << "\nMatritsa ko'rinishi:\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cout << a[i][j] << " "; cout << endl; } do { cout << "\nk-ustun nomerini kiriting="; cin >> k; } while (k < 0 || k >= m); cout << k << "-ustun maximal elementi =" << K_ustun_max(n, k, a); for (int i = 0; i < n; i++) delete[]a[i]; delete[]a; system(“pause”); return 0; } Dastur natijasi Download 0.58 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling