jeudi 27 décembre 2018

I want to convert the last output into an array in c++

I have this code and i want the last output it shows to be converted in an array so that it makes my work easy

At first it asks for the column number and then prints that column vertically in a respective order The final output is a table that is actually more than one output and i want it converted into an array

#include<iostream>

#include<stdio.h>
using namespace std;

main()

{

int e[100];
int f[100];
int n;

cout << "THINK OF A NUMBER AND ENTER THE NUMBER OF ALPHABETHS IT 
CONTAINS" << endl;
cin >> n;
char a[7]={'A','E','I','M','Q','U','Y'};
char b[7]={'B','F','J','N','R','V','Z'};
char c[6]={'C','G','K','O','S','W'};
char d[6]={'D','H','L','P','T','X'};


for(int i=0;i<7;i++)
{
    cout << a[i] << " "<< b[i] << " " << c[i] << " " << d[i];
    cout << endl;
}

for(int i=0;i<n;i++)

{
cout << "Enter the column number of alphabet number ["<<i<<"]"<<"of your 
word" << endl ;
cin>> e[i];
}
cout << endl;

for(int i=0;i<7;i++)
{
if(e[i]==1)
{

for(int i=0;i<7;i++)
  {
    cout << a[i] <<" " ;
  }
cout << endl;
}
else if(e[i]==2)
{

  for(int i=0;i<7;i++)
  {
       cout << b[i] <<" " ;
  }
cout << endl;
}
else if(e[i]==3)
{
    for(int i=0;i<7;i++)
    {

    cout << c[i] <<" " ;
    }
cout << endl;
}
else if(e[i]==4)
{
    for(int i=0;i<7;i++)
    {
    cout << d[i] <<" " ;
    }
cout << endl;
}
}

}

Aucun commentaire:

Enregistrer un commentaire