Jump to content
aurelL

Matricea

Recommended Posts

Salut. Am o problema, şi nu m.am descurcat prea bine. Sună cam aşa : Se dă o matrice cu N linii și M coloane, și un număr natural K. Să se ștearga linia K din matrice.

1 < K <= N,M < 500 ( Restrictii ).

*!!!* Coloanele / Liniile incep de la 1.

Ce am făcut eu : ( C ++ )

#include <iostream>
using namespace std;

int main()
{

    int N, M, matrice[500][500], K;
    cin >> N >> M >> K;
    int i, j;
    int j_copy = 1;
        for ( i = 1; i <= N; ++i )
            for ( j = 1; j <= M; ++j )
                cin >> matrice[i][j];
        for ( i = 1; i <= N; ++i ) {
            for ( j = 1; j <= M; ++j ) {
                while ( j_copy <= j ) {
                    cout << matrice[i][j] - matrice[K][j_copy];
                cout << "\n";
                ++j_copy;
                }
            }
        }
    return 0;
}

E praf codul stiu, la output nu-mi da nimic bun.

M-am gandit la ceva de genu : http://prntscr.com/lzqfm0

Help?

  • Upvote 1
Link to comment
Share on other sites

Nu înţeleg codul tău.

Date de intrare

Pe prima linie se citesc la tastatură numerele N, M, respectiv K, cu semnificațiile din enunț. Pe următoarele N linii se citesc M numere naturale.

 

Date de ieșire

Programul va afișa pe ecran matricea cu a K-a linie ștearsă.

Edited by aurelL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...