f0706.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:

C#编程

开发平台:

Visual C++

  1. //=====================================
  2. // f0707.cpp
  3. //=====================================
  4. #include<iostream>
  5. #include<iomanip>
  6. #include<fstream>
  7. using namespace std;
  8. //-------------------------------------
  9. const int row=100;
  10. const int col=100;
  11. int main(){
  12.   ifstream in("ab.txt");
  13.   int ma[row][col];
  14.   int mb[row][col];
  15.   int mc[row][col];
  16.   for(int r,c; in>>r>>c; ){
  17.     for(int i=0; i<r; ++i)
  18.     for(int j=0; j<c; ++j)
  19.       in>>ma[i][j];
  20.     for(int i=0; i<r; ++i)
  21.     for(int j=0; j<c; ++j)
  22.       in>>mb[i][j];
  23.     for(int i=0; i<r; ++i)
  24.     for(int j=0; j<c; ++j)
  25.       mc[i][j] = ma[i][j] + mb[i][j];
  26.     for(int i=0; i<r; ++i){
  27.       for(int j=0; j<c; ++j)
  28.         cout<<setw(4)<<mc[i][j];
  29.       cout<<endl;
  30.     }
  31.   }
  32. }//====================================
  33.