Tekshirdi:Sherbekova Feruza Guruhi: 007-L1 13 – Variant Savol - Natural n va m hamda haqiqiy sonli A(1:n,1:m)massiv berilgan bo’lsin. Shu massivning har bir satridagi eng katta elementlar ichidan eng kichigini toping. #include using namespace std; void kLargest(int arr[], int n, int k) { sort(arr, arr + n, greater()); for (int i = 0; i < k; i++) cout << arr[i] << " "; } int main() { int arr[] = { 1, 23, 12, 9, 30, 2, 50 }; int n = sizeof(arr) / sizeof(arr[0]); int k = 3; kLargest(arr, n, k); }
Dev C++
Javobi
Do'stlaringiz bilan baham: |