首页 > 代码库 > cf B Three matrices

cf B Three matrices

技术分享
 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5  6 int g[200][200]; 7 int n; 8  9 int main()10 {11      while(scanf("%d",&n)!=EOF)12      {13          for(int i=1; i<=n; i++)14          {15              for(int j=1; j<=n; j++)16              {17                  scanf("%d",&g[i][j]);18              }19          }20          for(int i=1; i<=n; i++)21          {22              for(int j=1; j<=n; j++)23              {24                  if(i==j)25                  {26                      printf("%.8lf ",(double)g[i][j]);27                  }28                  else29                  {30                      printf("%.8lf ",(double)((g[i][j]+g[j][i])*1.0/2));31                  }32              }33              printf("\n");34          }35          for(int i=1; i<=n; i++)36          {37              for(int j=1; j<=n; j++)38              {39                  if(i==j) printf("%.8lf ",(double)0);40                  else41                  {42                      printf("%.8lf ",(double)((double)g[i][j]-(g[i][j]+g[j][i])*1.0/2));43                  }44              }45              printf("\n");46          }47      }48      return 0;49 }
View Code

 

cf B Three matrices