Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <iomanip>
- #include <time.h>
- using namespace std;
- const int B = 20, A = 20;
- int foo(int* p);
- /////////////////////////////////////////////////
- int main()
- {
- srand(time(0));
- int array[B];
- int mas[B];
- for(int i = 0; i < B; i++)
- {
- mas[i] = rand() % 100 - 10;
- array[i] = rand() % 100 - 10;
- cout << " " << setw(3) << array[i] << " "
- << setw(3) << mas[i] << endl;
- }
- int v = foo(array);
- int g = foo( mas);
- cout << " array[i] =" << v << endl;
- cout << " mas[i] =" << g << endl;
- if(v < g)
- {
- // cout << " foo(mas) = " << foo(mas) << endl;
- // if (g < foo(array))
- // {
- // cout << " foo(array) = " << foo(array) << endl;
- // }
- cout << "Win array" << endl;
- }
- if(g < v) cout << "Win mas" << endl;
- /* cout << endl;
- for (int j = 0; j < B; j++) {
- mas[j] = rand() % 10;
- cout << " " << mas[j];
- }*/
- }
- int foo(int* p)
- {
- int i = 0;
- for (int i = 0; i < B; i++)
- {
- if (p[i] < 0)
- {
- return i;
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement