Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- #include <iomanip>
- using namespace std;
- int const n = 10;
- int const n1 = 5;
- int f(int x[]){
- int ind = 0;
- for (int i = 0; i < n; i++){
- if (x[i] > 0){
- ind = i;
- }
- }
- return ind;
- }
- int main(){
- int a[n];
- int b[n1];
- int mina = 999, minb = 999;
- for (int i = 0; i < n; i++){ // инициализация
- a[i] = rand()%100 - 50;
- cout << setw(4) << a[i];
- }
- cout << '\n';
- for (int i = 0; i < n1; i++){ // инициализация
- b[i] = rand()%100 - 50;
- cout << setw(4) << b[i];
- }
- for (int i = 0; i < f(a); i++){ // минимум в массиве а
- if (a[i] < mina){
- mina = a[i];
- }
- }
- cout << '\n' << mina;
- for (int i = 0; i < f(b); i++){ // минимум в массиве а
- if (b[i] < minb){
- minb = b[i];
- }
- }
- cout << '\n' << minb;
- }
Add Comment
Please, Sign In to add comment