fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,m;
  6. cin >> n >> m;
  7. double A[n][m];
  8. for (int i = 0; i < n; i++){
  9. for (int j = 0; j < m; j++)
  10. cin >> A[i][j];
  11. }
  12. for (int i = 0; i < n; i++){
  13. for (int j = 0; j < m; j++)
  14. if (A[i][j]!=0){
  15. A[i][j]=-(1/A[i][j]);
  16. }
  17. }
  18. for (int i = 0; i < n; i++){
  19. for(int j = 0; j < m; j++)
  20. cout << A[i][j] << "\t";
  21. cout << endl;
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 3432KB
stdin
3 4
1 1 1 1
1 1 1 1
1 1 1 1
stdout
-1	-1	-1	-1	
-1	-1	-1	-1	
-1	-1	-1	-1