[5-1]

#include<stdio.h>

main()

{

 float A[2][2],B[2][2],C[2][2],det;

 int i,j,k;

 

 printf("Enter matrix A:\n");

 for(i=0;i<2;++i){

    for(j=0;j<2;++j){

       printf("A[%d][%d]= ",i+1,j+1);

       scanf("%f",&A[i][j]);

    }

 }

 

 det=A[0][0]*A[1][1]-A[0][1]*A[1][0];

 

 if(det!=0){

   B[0][0]=A[1][1]/det;

   B[0][1]=-A[0][1]/det;

   B[1][0]=-A[1][0]/det;

   B[1][1]=A[0][0]/det;

 

   for(i=0;i<2;++i)

      for(j=0;j<2;++j){

         C[i][j]=0;

         for(k=0;k<2;++k)

            C[i][j]+=A[i][k]*B[k][j];

      }

 

   printf("inv(A):\n");

   for(i=0;i<2;++i){

      for(j=0;j<2;++j)

         printf("%10.4f ", B[i][j]);

      printf("\n");

   }

 

   printf("A*inv(A):\n");

   for(i=0;i<2;++i){

      for(j=0;j<2;++j)

         printf("%4.1f ", C[i][j]);

      printf("\n");

   }

 }

 else

   printf("No inv(A) existed.\n");

}

 

[5-2]

#include<stdio.h>

main()

{

 int score[5][2][3]={{{25,77,82},{56,78,69}},

                     {{67,75,70},{72,74,77}},

                     {{85,92,87},{84,100,78}},

                     {{98,63,78},{91,70,81}},

                     {{73,88,88},{79,90,92}}};

 int max=0;

 int i,j,k,im,jm,km;

 char person[5]={'A','B','C','D','E'};

 char exams[2][5]={"",""};

 char subject[3][5]={"p","w",""};

 

 

 for(i=0;i<5;++i){

    for(j=0;j<2;++j){

       for(k=0;k<3;++k){

          if(max<score[i][j][k]){

             max=score[i][j][k];

             im=i; jm=j; km=k;

          }

       }

    }

 }

 

 printf("ō_F%d\n",max);

 printf("_ҁF%c\n",person[im]);

 printf("ʁF%s\n",exams[jm]);

 printf("ȁ@ځF%s\n",subject[km]);

}

yʉz

#include<stdio.h>

main()

{

 int score[5][2][3]={{{25,77,82},{56,78,69}},

                     {{67,75,70},{72,74,77}},

                     {{85,92,87},{84,100,78}},

                     {{98,63,78},{91,70,81}},

                     {{73,88,88},{79,90,92}}};

 int max=0;

 int i,j,k,im,jm,km;

 

 for(i=0;i<5;++i){

    for(j=0;j<2;++j){

       for(k=0;k<3;++k){

          if(max<score[i][j][k]){

             max=score[i][j][k];

             im=i; jm=j; km=k;

          }

       }

    }

 }

 

 printf("ō_F%d\n",max);

 printf("_ҁF");

 switch(im){

    case 0: printf("A\n"); break;

    case 1: printf("B\n"); break;

    case 2: printf("C\n"); break;

    case 3: printf("D\n"); break;

    case 4: printf("E\n"); break;

 }

 printf("ʁF");

 switch(jm){

    case 0: printf("\n"); break;

    case 1: printf("\n"); break;

 }

 printf("ȁ@ځF");

 switch(km){

    case 0: printf("p\n"); break;

    case 1: printf("w\n"); break;

    case 2: printf("\n"); break;

 }

}