samedi 20 avril 2019

how to display a 3 x 3, 2d array but with the last row only displaying 1 column

i have declared a 2d , 3x3 array..it will display 3 rows and 3 columns..what i want is for the 3rd row only to display 1 column...how can i do this please..

#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

int main()
{
    string names[3][3]= {};

    for (int i = 0; i < 3; i++)
    {
        cout<<"    ";
      for (int j = 0; j < 3; j++)
      {
        cout<<i<<j<<"  ";

      }
      cout<<endl;
    }

    getch();
  system("pause");
  return 0;

}

Aucun commentaire:

Enregistrer un commentaire