Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Largest element :
#include<bits/stdc++.h>
using namespace std;
int find_largest(int nums[], int n) {
return *max_element(nums, nums + n);
}
int main() {
int nums[] = {
5,
4,
9,
12,
8
};
int n = sizeof(nums) / sizeof(nums[0]);
cout << "Original array:";
for (int i=0; i < n; i++)
cout << nums[i] <<" ";
if (arr_size < 3)
{
cout << "Invalid Input";
}
cout << "\nThree largest elements are: " <<first <<", "<< second
<<", "<< third;
}
int main()
{
int nums[] = {7, 12, 9, 15, 19, 32, 56, 70};
int n = sizeof(nums)/sizeof(nums[0]);
cout << "Original array: ";
for (int i=0; i < n; i++)
cout << nums[i] <<" ";
three_largest(nums, n);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int nums[] = {4, 5, 9, 12, 9, 22, 45, 7};
int n = sizeof(nums)/sizeof(nums[0]);
cout << "Original array: ";
for (int i=0; i < n; i++)
cout << nums[i] <<" ";
most_occurred_number(nums, n);
}
#include <bits/stdc++.h>
using namespace std;
result = !result;
}
int main()
{
int nums[] = {0, 1, 3, 4, 5, 6, 7, 8, 10};
int n = sizeof(nums)/sizeof(nums[0]);
cout << "Original array: ";
for (int i=0; i < n; i++)
cout << nums[i] <<" ";
rearrange_max_min(nums, n);