fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int f, c, i, j;
  6. cin>>f>>c;
  7. int a[f][c];
  8. for(i=0; i<f; i++){
  9. for(j=0; j<c; j++){
  10. cin>>a[i][j];
  11. }
  12. }
  13. //Recorrido por fila
  14. for(i=0; i<f; i++){
  15. for(j=0; j<c; j++){
  16. cout<<a[i][j]<<' ';
  17. }
  18. cout<<'\n';
  19. }
  20. // Mostrar elemntos en los bordes
  21. for(i=0; i<f; i++){
  22. for(j=0; j<c; j++){
  23. if(i==0 || i==f-1 || j==0 || j==c-1)
  24. cout<<a[i][j]<<' ';
  25. }
  26. cout<<'\n';
  27. }
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5276KB
stdin
1 2 3
1 4 5
3 2 1
stdout
3 1 
3 1