Advertisement
dllbridge

Untitled

May 14th, 2025
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1.  
  2. #include   <iostream>
  3. #include   <stdlib.h>
  4. #include    <iomanip>
  5. #include     <time.h>
  6. using namespace  std;
  7.  
  8.  
  9.  
  10. const int B = 20, A = 20;
  11. int foo(int* p);
  12.  
  13. /////////////////////////////////////////////////
  14. int main()
  15. {
  16.    
  17.     srand(time(0));
  18.     int  array[B];
  19.     int    mas[B];
  20.    
  21.     for(int i = 0; i < B; i++)
  22.     {
  23.  
  24.           mas[i] = rand() % 100 - 10;
  25.         array[i] = rand() % 100 - 10;
  26.        
  27.         cout << " " << setw(3) << array[i] << "   "
  28.                     << setw(3) <<   mas[i] << endl;    
  29.     }
  30.    
  31.     int v = foo(array);
  32.     int g = foo(  mas);
  33.    
  34.     cout << " array[i] =" << v << endl;
  35.     cout << "   mas[i] =" << g << endl;
  36.  
  37.     if(v < g)
  38.     {
  39.     //  cout << "  foo(mas) = " << foo(mas) << endl;
  40.     //  if (g < foo(array))
  41.     //  {
  42.     //      cout << "  foo(array)  =  " << foo(array) << endl;
  43.     //  }
  44.               cout << "Win array" << endl;
  45.     }
  46.     if(g < v) cout << "Win   mas" << endl;
  47.  
  48.    
  49. /*              cout << endl;
  50.     for (int j = 0; j < B; j++) {
  51.  
  52.         mas[j] = rand() % 10;
  53.              
  54.         cout << " " << mas[j];
  55.     }*/
  56. }
  57.  
  58.  
  59. int foo(int* p)
  60. {
  61.     int i = 0;
  62.     for (int i = 0; i < B; i++)
  63.     {
  64.         if (p[i] < 0)
  65.         {
  66.             return i;
  67.         }
  68.    
  69.     }
  70.     return -1;
  71.  }
  72.  
  73.  
  74.  
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement