Hey can anybody help me find a way to input values from the keyboard into a 3 X 3 matrix. I'm having difficulty with even the simplist task.
here's what i have so far.
#include <iostream>
#include <fstream>
using namespace std;
const int SIZE = 3;
int row;
int col;
int PBUF[3][3];
int QBUF[3][3];
int RBUF[3][3];
int main()
{
int choice;
do
{
cout << endl
<< "Choose 1 to input two arrays from the keyboard.\n"
<< "Choose 2 to input two arrays from a file.\n"
<< "Choose 3 to display the input file data, buffer data, and output file data.\n"
<< "Choose 4 to write input file data, buffer data, and output file' on a file.\n"
<< "Choose 5 to exit the program";
cin >> choice;
switch (choice)
{
case 1:
{
for( col = 0; col < SIZE ; col ++ )
for( row = 0; row < SIZE; row ++ )
cin >> PBUF[col][row];
}
{
for( col = 0; col < SIZE ; col ++ )
for( row = 0; row < SIZE; row ++ )
cin >> QBUF[col][row];
}
cout << endl;
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
cout << "End of program.\n";
break;
default:
cout << "Not a valid choice.\n"
<< "Choose again.\n";
}
} while (choice !=5);
return 0;
}
here's what i have so far.
#include <iostream>
#include <fstream>
using namespace std;
const int SIZE = 3;
int row;
int col;
int PBUF[3][3];
int QBUF[3][3];
int RBUF[3][3];
int main()
{
int choice;
do
{
cout << endl
<< "Choose 1 to input two arrays from the keyboard.\n"
<< "Choose 2 to input two arrays from a file.\n"
<< "Choose 3 to display the input file data, buffer data, and output file data.\n"
<< "Choose 4 to write input file data, buffer data, and output file' on a file.\n"
<< "Choose 5 to exit the program";
cin >> choice;
switch (choice)
{
case 1:
{
for( col = 0; col < SIZE ; col ++ )
for( row = 0; row < SIZE; row ++ )
cin >> PBUF[col][row];
}
{
for( col = 0; col < SIZE ; col ++ )
for( row = 0; row < SIZE; row ++ )
cin >> QBUF[col][row];
}
cout << endl;
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
cout << "End of program.\n";
break;
default:
cout << "Not a valid choice.\n"
<< "Choose again.\n";
}
} while (choice !=5);
return 0;
}
Comment