Advertisement
OHYtheAwesome

Arrays

Mar 21st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <array>
  5.  
  6. using namespace std;
  7.  
  8. void titato (string a[][3]) { //to use a multidimensional array as parameters you need to make sure you put the number in the last []
  9.     int n;
  10.     int m;
  11.     string d;
  12.     for ( m = 0; m<3; ++m){
  13.         for ( n = 0; n<3; ++n) {
  14.             d = a[m][n];
  15.             cout << d << " ";
  16.         }
  17.         cout << endl;
  18.     }
  19. }
  20.  
  21. int main() {
  22.     int numbers[5] = {16, 27, 7, 40, 12071}; //this is an ordinary array
  23.     int x = numbers[0];
  24.     int n;
  25.     string tic[3][3] = {{"x", "o", "x"}, {"x", "o", "x"}, {"o", "x", "o"}}; //this is a multidimensional array
  26.     cout << x << endl;
  27.     numbers[0] = 1;
  28.     x = numbers[0];
  29.     cout << x << endl;
  30.     for ( n=0 ; n<5 ; ++n ) {
  31.         cout << numbers[n] << " " << endl;
  32.       }
  33.     titato(tic);
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement