Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Parcurgerea unei matrici
- // a) afisare normala
- // b) coloane de jos in sus
- // c) elementele de pe contur
- #include <iostream>
- using namespace std;
- int main()
- {
- int i, j, m, n, a[100][100];
- cout << "Introduceti numarul de linii: ";
- cin >> n;
- cout << "Introduceti numarul de coloane: ";
- cin >> m;
- for(i = 1; i <= n; i++)
- for(j = 1; j <= m; j++) {
- cout << "a[" << i << "][" << j << "]=";
- cin >> a[i][j];
- }
- cout << endl << "Parcurgerea normala a matricei: \n";
- for(i = 1; i <= n; i++) {
- for(j = 1; j <= m; j++)
- cout << a[i][j] << " ";
- cout << endl;
- }
- cout << "\n\n\nParcurgerea pe coloane de jos in sus: \n";
- for(i = n; i >= 1; i--) {
- for(j = 1; j <= m; j++)
- cout << a[i][j] << " ";
- cout << endl;
- }
- cout << "\n\n\nParcurgerea elementelor de pe contur: \n";
- for(j = 1; j <= m; j++)
- cout << a[1][j] << " ";
- for(i = 2; i < n; i++)
- cout << a[i][m] << " ";
- for(j = m; j >= 1; j--)
- cout << a[n][j] << " ";
- for(i = n - 1; i > 1; i--)
- cout << a[i][1] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment