-
-
Save AlexandruFilipescu/dd112cb5e23090b615b3f1f956e93904 to your computer and use it in GitHub Desktop.
C++ Matrice parcursa cu un singur FOR V2(C++ matrix looped with single FOR)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int matrice[50][50],l,c,k,j; | |
int main() { | |
cout << "Introduceti numarul de linii: "; | |
cin >> l; | |
cout << "\nIntroduceti numarul de coloane: "; | |
cin >> c; | |
cout << "\nIntroduceti elementele matricii: "; | |
for (int i = 0; i < l; i++) { | |
for (int j = 0; j < c; j++) { | |
cin >> matrice[i][j]; | |
} | |
} | |
for (int i = 0; i < l*c; i++) { | |
cout << matrice[i/c][i%c] << " "; | |
if ((i + 1) %c == 0 ) { | |
cout << endl; | |
} | |
} | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment