I can not interpret the problem raised [closed]

0

I just need help to understand it ... Make a program that asks what number you want to fill all the positions of a matrix, you choose the length of the matrix, then the matrix must appear with all the values that the user chose and the diagonal must be filled with the number 1.

    
asked by Sam Padilla 19.10.2017 в 17:52
source

2 answers

0

Based on the phrase:

  

with what number you want to fill all the positions of a matrix

Talk about requesting ONE number with which to fill ALL the positions. It seems pretty clear, otherwise you should have put:

... with what number S you want to fill each of the positions ...

    
answered by 19.10.2017 / 18:33
source
0

Thanks for your help, I leave the code:

#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
    int numero, matriz[4][4];

    cout << "Ingrese un numero para rellenar la matriz ";
    cin >> numero;
    cout << endl;
    cout << "Tu matriz resultado es:" << endl << endl;;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++) {
            if (i == j) {
                matriz[i][j] = 1;
                cout << matriz[i][j]<<"     ";
            }
            else {
                matriz[i][j] = numero;
                cout << matriz[i][j]<<"     ";
            }
        }
        cout << endl;
        cout << endl;
    }
    system("PAUSE");
    return 0;
}
    
answered by 19.10.2017 в 19:37