- Информатика
- #include using namespace
#include using namespace std;
//5 3 6 2 1
int second_max(int *arr, int n) {
int max_index = 0;//max = 5
for(int i = 1; i < n; i++) {
if(arr[i] > arr[max_index])
max_index = i;
}
int max2 = arr[0];
for(int i = 0; i < n; i++) {
if(i == max_index)
continue;
if(arr[i] > max2) {
max2 = arr[i];
}
}
return max2;
}
//HOME Task
double getAverage(int *arr, int n) {
return 0;
}
int second_max(int *arr, int n) {
return 0;
}
int sum(int *arr, int n) {
return 0;
}
int find(int *arr, int n, int key) {
return the index of key, otherwise
return -1;
}
void mysort(int *arr, int n) {
}
int main() {
int arr[5];
for(int i = 0; i < 5; i++) {//i = 0
arr[i] = i+1;
}
int n = sizeof(arr)/sizeof(int);
cout << second_max(arr, n) << endl;
cout << find(arr, n, 5) << endl;
//4
}
/*
bool, char, int, float, double, long
size/range
int -> 4 bytes, 4bytes -> bit
arithmetic: + - * / %
assignment: =, +=, -=, ...
logical: !, ||, &&
relational: >, <, <=, >=, ==, !=
auto incr/decr: ++, --
bitwise: |, &, xor
selection structure: if else, switch case, ternary op
loop structure: while, for, do while
*/