Advertisement
CosminVarlan

Untitled

Nov 5th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a[10] = {4,3,7,9,2,5,8};
  6.  
  7. int m[3][3] {{1,2,3},{4,5,6},{7,8,9}};
  8.  
  9.  
  10. int maxim(int x[], int n)
  11. {
  12.     int maxim = x[0];
  13.     for(int i=1; i<n; i++)
  14.     {
  15.  
  16.         if ( maxim < x[i] ) maxim = x[i];
  17.     }
  18.     return maxim;
  19. }
  20.  
  21.  
  22. void schimba(int &a, int &b)
  23. {
  24.     cout << "Adresa lui a este: "<< &a << endl;
  25.     int c=a;
  26.     a=b;
  27.     b=c;
  28.     cout << a << " " << b << endl;
  29. }
  30.  
  31.  
  32.  
  33. int maximm(int x[][3], int n, int m)
  34. {
  35.     int maxim = x[0][0];
  36.     for(int i=0; i<n; i++)
  37.         for(int j=0; j<m; j++)
  38.         {
  39.             if ( maxim < x[i][j] ) maxim = x[i][j];
  40.         }
  41.     return maxim;
  42. }
  43.  
  44.  
  45. int main()
  46. {
  47.     cout << &a[0]<<endl;
  48.     cout << &a[1]<<endl;
  49.     cout << &a[2]<<endl;
  50.     cout << &a[3]<<endl;
  51.     cout << &a[4]<<endl;
  52.     cout << &a[5]<<endl;
  53.  
  54.     cout << a[0]<<endl;
  55.     cout << a[1]<<endl;
  56.     cout << a[2]<<endl;
  57.     cout << a[3]<<endl;
  58.  
  59.  
  60.     cout << a <<endl;
  61.     cout << a+1 <<endl;
  62.     cout << a+2 <<endl;
  63.     cout << a+3 <<endl;
  64.  
  65.     cout << "maxim=" << maxim(a,7) <<endl;
  66.     cout << a[0] << endl;
  67.  
  68.  
  69.     int a1=3,b1=4;
  70.     cout << "Adresa lui a este: "<< &a1 << endl;
  71.  
  72.     schimba(a1, b1);
  73.  
  74.     cout << a1 << " " << b1 << endl;
  75.  
  76.     cout << endl << endl;
  77.     for(int i=0; i<3; i++)
  78.     {
  79.         for(int j=0; j<3; j++)
  80.             cout << m[i][j]<< " ";
  81.         cout << endl;
  82.     }
  83.  
  84.     cout << m << endl;
  85.     cout << m[0] << endl;
  86.     cout << m[1] << endl;
  87.     cout << m[2] << endl;
  88.  
  89.     cout << maximm(m,3,3) << endl;
  90.  
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement