[c] przekazywanie funkcji przez referencję

kawafis44
Użytkownik
Użytkownik
Posty: 474
Rejestracja: 22 paź 2007, o 20:55
Płeć: Mężczyzna
Lokalizacja: Gliwice
Podziękował: 416 razy
Pomógł: 2 razy

[c] przekazywanie funkcji przez referencję

Post autor: kawafis44 »

Właśnie się dowiedziałem, że w C ponoć nie można przekazywać funkcji przez referencję, tylko przez wartość. Podejrzewam jednak, ze da się jakoś ten problem "obejść" przez użycie wskaźników, tylko nie wiem, jak dokładnie.

Kod: Zaznacz cały

void funkcja(int alfa, int beta)
{
   alfa = 3;
   beta = 4;
}

main()
{
   int aa=0,bb=0;
   funkcja(aa,bb);
   printf("[%d,%d]",aa,bb);
   getch();
}
Jak zmodyfikować ten kod, żeby przekazywało przez referencję, a nie przez wartość? Program wyświetla [0,0], a chciałbym, żeby było to [3,4].
Pozdro!
Awatar użytkownika
Undre
Użytkownik
Użytkownik
Posty: 1430
Rejestracja: 15 lis 2004, o 02:05
Płeć: Mężczyzna
Lokalizacja:
Podziękował: 3 razy
Pomógł: 92 razy

[c] przekazywanie funkcji przez referencję

Post autor: Undre »

Kod: Zaznacz cały

#include <stdio.h>
void funkcja(int * alfa, int * beta)
{
   *alfa = 3;
   *beta = 4;
}
int main(void)
{
  int aa=0,bb=0;
  funkcja(&aa,&bb);
  printf("[%d,%d]",aa,bb);
  getch();
  return 0;
}
kawafis44
Użytkownik
Użytkownik
Posty: 474
Rejestracja: 22 paź 2007, o 20:55
Płeć: Mężczyzna
Lokalizacja: Gliwice
Podziękował: 416 razy
Pomógł: 2 razy

[c] przekazywanie funkcji przez referencję

Post autor: kawafis44 »

Pojawia mi się błąd przy kompilacji
726 - matrix_calculator2.c - warning: passing arg 1 of `Determine_the_proper_sequence' from incompatible pointer type

Kod: Zaznacz cały

//application can be properly compillated in Dev-C++ 4
//if you cannot compile it in other program include conio.h !!!!!!!!!!
//(you also can change all getch() into getchar())
//in both cases application will look worse but still can work
#include <stdio.h>
//#include <conio.h>  //for getch()
//#include <stdlib.h> //for system("pause") ?
//#include <cstdlib.h> //library for cleaning the screen (stdlib.h ??)

struct matrices
{
int owned; //do you own this matrix
int sizea, sizeb; //what is the size of matrix, a-rows, b-columns
float values[25][25]; //every element of this matrix
} matrix[27]; //there are 27 matrices

int rows[255], columns[255];

char choose_opt()
{
   char temp_opt;
   
   system("cls");
   printf("Matrix calculator \n\
   (a) Create new matrix \n\
   (b) Edit existing matrix \n\
   (c) Show existing matrix \n\
   (d) Delete existing matrix \n\
   (e) Save matrices to the file \n\
   (f) Load matrices from the file \n\
   (g) Transposition (MxN)^T = (NxM) \n\
   (h) Addition (MxN)+(MxN)=(MxN) \n\
   (i) Scalar multiplication c*(MxN)=(MxN) \n\
   (j) Matrix multiplication (MxN)x(NxP)=(MxP)\n\
   (k) Exponentiation (MxM)^c=(MxM) \n\
   (l) Determinant det[(MxM)]=c\n\
   (m) Inverse (MxM)^(-1)=(MxM) if det[(MxM)]<>0\n\
   (n) About the program\n\
   (o) Exit the application\n");
   
   do
   {
      printf("Choose your option.");
      temp_opt = getch();
      //printf("((%c))",temp_opt);
      if ((temp_opt < 'a')||(temp_opt > 'o'))
         printf("\nImproper choice. ");
      else
         printf("\n");
   } while ((temp_opt < 'a')||(temp_opt > 'o'));
   system("cls");
   return temp_opt;
}

void Show_owned()
{
   int i;
   int do_you_own_any_matrix=0; //check wheter there are any owned matrices
   for (i=0;i<27;i++)
    if (matrix[i].owned)
         {
            do_you_own_any_matrix=1;
            break;
         }
         
   if (do_you_own_any_matrix) //if there are, show which one
   {
      printf("You own these matrices: ");
      for (i=0;i<27;i++)
         {
         if (matrix[i].owned==1)
            printf("%c",'a'+i-1);
         }
   }
   else
      printf("You do not own any matrix.");
}

void Func_a()
{
   char temp_opt_local; //letter as name of the matrix
   int temp_opt_local_number; //number of letter
   int siza,sizb; //size of new matrix
   int error; //to avoid giving improper value of 1) size, 2)n-th element of matrix
   int i,j; //loop used for filling values of the matrix
   float act_value; //actual value when filling values of the matrix

   //CHOOSE THE LETTER as a name for your new matrix
   printf("[CREATE A NEW MATRIX]\n");
   Show_owned(); //SHOW MATRICES OWNED by the user
   printf("\nChoose the letter for a new matrix (zero for exit).");
   do
   {
      fflush(stdin); //very important line - it clears standard input
      temp_opt_local = getch();
      if (temp_opt_local == '0') {printf("\nYou have not created new matrix");break;}
      if ((temp_opt_local < 'a')||(temp_opt_local > 'z'))
         {printf("\nYou must choose the letter. ");continue;}
      temp_opt_local_number = (int)temp_opt_local-(int)'a'+1; //int x; char y; x=(int)y writes number of symbol y in ascii table
      if (matrix[temp_opt_local_number].owned==1)
         {printf("\nThis letter is already assigned to a matrix. You must choose another letter. ");continue;} //continue is not needed
      else
         {
            //printf("\nYour choise is proper: %c. ",temp_opt_local);
            break;
         }
   } while (1==1);

   if (temp_opt_local != '0')//((temp_opt_local >= 'a')&&(temp_opt_local <= 'z'))
   {
      //after choosing the letter, DETERMINE THE SIZE of the matrix
      siza=0;sizb=0;
      printf("\nWrite two numbers (first for number of rows, second for columns). Use space to");
      printf("\nseparate these two numbers. They must be integers between 1 and 25.");
      do
      {
         printf("\nThe size of the matrix: ");
         fflush(stdin); //very important line - it clears standard input
         error = scanf("%d %d",&siza,&sizb); //error becomes number of correctly read inputs
      } while ((error!=2)||(siza<1)||(siza>25)||(sizb<1)||(sizb>25));
      matrix[temp_opt_local_number].sizea=siza;
      matrix[temp_opt_local_number].sizeb=sizb;

      //CHOOSE VALUES for all fields of the matrix
      printf("You will be able to change every one single value after filling all the matrix.\n");
      for (i=0;i<((matrix[temp_opt_local_number].sizea));i++)
      {
         for (j=0;j<((matrix[temp_opt_local_number].sizeb));j++)
         {
            do
            {
               printf("The element [%d,%d] of the matrix: ",(i+1),(j+1));
               fflush(stdin); //very important line - it clears standard input
               error = scanf("%f",&act_value); //error becomes number of correctly read inputs
            } while ((error!=1));
            matrix[temp_opt_local_number].values[i][j]=act_value;
         }
      }

      //DISABLE USED LETTER
      matrix[temp_opt_local_number].owned=1;
   }
}

void Choose_letter(int *chosen_letter_number, int *if_not_chosen)
{
   char temp;
   int temp_nr;
   *if_not_chosen=0;
   //CHOOSE THE LETTER of existing matrix
   printf("\nChoose the letter of the existing matrix (zero for exit).");
   do
   {
      fflush(stdin); //very important line - it clears standard input
      temp = getch();
      if (temp == '0') {printf("\nYou have not chosen any matrix");*if_not_chosen=1;break;}
      if ((temp < 'a')||(temp > 'z'))
         {printf("\nYou must choose the letter. ");continue;}
      temp_nr = (int)temp-(int)'a'+1; //int x; char y; x=(int)y writes number of symbol y in ascii table
      if (matrix[temp_nr].owned==0)
         {printf("\nThis matrix does not exist. You must choose another letter. ");continue;} //continue is not needed
      else
         {printf("\nYou have chosen this matrix: %c. ",temp); break;}
   } while (1==1);
   if (*if_not_chosen == 0) *chosen_letter_number = temp_nr;
}

void Choose_letter_for_new(int *chosen_letter_number, int *if_not_chosen)
{
   char temp;
   int temp_nr;
   *if_not_chosen=0;
   //CHOOSE THE LETTER of NON-existing matrix
   printf("\nChoose the letter for the new matrix (zero for exit).");
   do
   {
      fflush(stdin); //very important line - it clears standard input
      temp = getch();
      if (temp == '0') {printf("\nYou have not chosen any matrix");*if_not_chosen=1;break;}
      if ((temp < 'a')||(temp > 'z'))
         {printf("\nYou must choose the letter. ");continue;}
      temp_nr = (int)temp-(int)'a'+1; //int x; char y; x=(int)y writes number of symbol y in ascii table
      if (matrix[temp_nr].owned==1)
         {printf("\nThis matrix exists. You must choose another letter. ");continue;} //continue is not needed
      else
         {printf("\nYou have created new matrix: %c. ",temp); break;}
   } while (1==1);
   if (*if_not_chosen == 0) *chosen_letter_number = temp_nr;
}

void Show_matrix(int letter_nr)
{
      int i,j;
      int max[255];
      //determine for each column maximum number of characters which are needed to show the number
      //for (i=0;i<255;i++) max[i]=0;
      for (i=0;i<(matrix[letter_nr].sizea);i++)
      {
         for (j=0;j<(matrix[letter_nr].sizeb);j++)
         {
            if (i==0) max[j]=0;
            do {
               if ((abs(matrix[letter_nr].values[i][j])<10))       {if (max[j]<=1) {max[j]=1;if (matrix[letter_nr].values[j][i]<0) max[j]++;}break;}
               if ((abs(matrix[letter_nr].values[i][j])<100))      {if (max[j]<=2) {max[j]=2;if (matrix[letter_nr].values[j][i]<0) max[j]++;}break;}
               if ((abs(matrix[letter_nr].values[i][j])<1000))     {if (max[j]<=3) {max[j]=3;if (matrix[letter_nr].values[j][i]<0) max[j]++;}break;}
               if ((abs(matrix[letter_nr].values[i][j])<10000))    {if (max[j]<=4) {max[j]=4;if (matrix[letter_nr].values[j][i]<0) max[j]++;}break;}
               if ((abs(matrix[letter_nr].values[i][j])<100000))   {if (max[j]<=5) {max[j]=5;if (matrix[letter_nr].values[j][i]<0) max[j]++;}break;}
               if ((abs(matrix[letter_nr].values[i][j])<1000000))  {if (max[j]<=6) {max[j]=6;if (matrix[letter_nr].values[j][i]<0) max[j]++;}break;}
               if ((abs(matrix[letter_nr].values[i][j])<10000000)) {if (max[j]<=7) {max[j]=7;if (matrix[letter_nr].values[j][i]<0) max[j]++;}break;}
               break;
            } while (1==1);
            //if (matrix[letter_nr].values[j][i]<0) max[j]++; ==> for symbol minus
            //it may waste one field if the value with the greatest number of digits is negative but I do not care
            ///printf("(((%d)))",max[j]); //test line
         }
      }
      ///for (j=0;j<(matrix[letter_nr].sizeb);j++)
      ///{printf("[[[%d]]]",max[j]);} //test line

      //printf("\nTHIS IS THE MATRIX:\n");
      //show the matrix
      printf("\n");
      for (i=0;i<(matrix[letter_nr].sizea);i++)
      {
         if ((matrix[letter_nr].sizea)>2) //left line
         {
            if (i==0)                                       printf("%c ",(char)218);
            if ((i!=0)&&(i!=((matrix[letter_nr].sizea)-1))) printf("%c ",(char)179);
            if (i==((matrix[letter_nr].sizea)-1))           printf("%c ",(char)192);
         }
         else
         {
            printf("[");
         }

         for (j=0;j<(matrix[letter_nr].sizeb);j++) //values
         {
            printf("%*.0f",max[j],(matrix[letter_nr].values[i][j]));
            if ((matrix[letter_nr].sizeb)!=(j+1)) printf(" ");
         }

         if ((matrix[letter_nr].sizea)>2) //right line
         {
            if (i==0)                                       printf("%c",(char)191);
            if ((i!=0)&&(i!=((matrix[letter_nr].sizea)-1))) printf("%c",(char)179);
            if (i==((matrix[letter_nr].sizea)-1))           printf("%c",(char)217);
         }
         else
         {
            printf("]");
         }
         printf("\n");
      }
      printf("If the matrix is not shown properly, use option [b - edit the matrix]");
      printf("\nand browse the matrix with no using editing function.");
}

void Func_c()
{
   int letter_nr;
   int not_chosen;
   //int i,j;
   //int max[255];
   //int number_of_fields;
   printf("[SHOW THE EXISTING MATRIX]\n");
   Show_owned();
   Choose_letter(&letter_nr, &not_chosen);
   // printf("[%d][%d] ",letter_nr,not_chosen); //testing line

   if (not_chosen == 0)
   {
      Show_matrix(letter_nr);
   }
}

void Func_d()
{
   int letter_nr;
   int not_chosen;
   printf("[DELETE THE EXISTING MATRIX]\n");
   Show_owned();
   Choose_letter(&letter_nr, &not_chosen);
   if (not_chosen == 0)
   {
      printf("\nYOU HAVE DELETED THIS MATRIX");
      matrix[letter_nr].owned=0;
   }
}

void Func_g() //Transposition (MxN)^T = (NxM)
{
   int letter_nr,letter_nr2;
   int not_chosen;
   int i,j;
   printf("[TRANSPOSITION (MxN)^T = (NxM)]\n");
   Show_owned();
   printf("\n*** Choose the inside matrix, which you want to transpose ***");
   Choose_letter(&letter_nr, &not_chosen);
   if (not_chosen == 0)
   {
      printf("\n*** Choose the outside matrix, which will contain trasposed matrix ***");
      Choose_letter_for_new(&letter_nr2, &not_chosen);
      if (not_chosen == 0)
      {
         //trasposition:
         //determine size of new matrix
         matrix[letter_nr2].owned=1;
         matrix[letter_nr2].sizea=matrix[letter_nr].sizeb;
         matrix[letter_nr2].sizeb=matrix[letter_nr].sizea;
         //choose values
         for (i=0;i<matrix[letter_nr].sizea;i++)
         {
            for (j=0;j<matrix[letter_nr].sizeb;j++)
            {
               matrix[letter_nr2].values[j][i]=matrix[letter_nr].values[i][j];
            }
         }
         //show the matrix
         Show_matrix(letter_nr2);
      }
   }
   if (not_chosen != 0)
   {
      printf("\nYou have abandoned creating transposed matrix...");
   }
}

void Func_h() //Addition (MxN)+(MxN)=(MxN)
{
   int letter_nr,letter_nr2,letter_nr3;
   int not_chosen;
   int i,j;
   printf("[ADDITION (MxN)+(MxN) = (MxN)\n");
   Show_owned();
   printf("\n*** Choose the first matrix ***");
   Choose_letter(&letter_nr, &not_chosen);
   if (not_chosen == 0)
   {
      printf("\n*** Choose the second matrix ***");
      Choose_letter(&letter_nr2, &not_chosen);
      //check the conditions
      if ((matrix[letter_nr].sizea==matrix[letter_nr2].sizea)&&(matrix[letter_nr].sizeb==matrix[letter_nr2].sizeb))
      {
         printf("\nOrder of matrices is proper");
      }
      else
      {
         printf("\n!!!!! Both matrices have to be of the same order !!!!!");
         not_chosen=1;
      }
      if (not_chosen == 0)
      {
         printf("\n*** Choose the outside matrix, which will contain the sum of matrices ***");
         Choose_letter_for_new(&letter_nr3, &not_chosen);
         if (not_chosen == 0)
         {
            //addition:
            //determine size of new matrix
            matrix[letter_nr3].owned=1;
            matrix[letter_nr3].sizea=matrix[letter_nr].sizea;
            matrix[letter_nr3].sizeb=matrix[letter_nr].sizeb;
            //add values
            for (i=0;i<matrix[letter_nr3].sizea;i++)
            {
               for (j=0;j<matrix[letter_nr3].sizeb;j++)
               {
                  matrix[letter_nr3].values[i][j]=matrix[letter_nr].values[i][j]+matrix[letter_nr2].values[i][j];
               }
            }
            //show the matrix
            Show_matrix(letter_nr3);
         }
      }
   }
   if (not_chosen != 0)
   {
      printf("\nYou have not created the sum of matrices...");
   }
}

void Func_i() //Scalar multiplication c*(MxN)=(MxN)
{
      int letter_nr,letter_nr2;
      int not_chosen;
      int i,j;
      float scalar;
      printf("[Scalar multiplication c*(MxN) = (MxN)]");
      //choose the scalar
      printf("\n*** Choose the scalar between -50 and 50 (100 for exit) ***");
      printf("\nYour choice: ");
      do
      {
         fflush(stdin);
         scanf("%f",&scalar);
         if (!((scalar<(-50))||(scalar>50)))
            {break;}
         else
            {
               if (scalar==100)
                  {printf("You have not chosen the scalar.");break;}
               else
                  {printf("Your choice is unproper. ");}
            }
      } while (1==1);
      //choose the matrices
      Show_owned();
      printf("\n*** Choose the input matrix ***");
      Choose_letter(&letter_nr, &not_chosen);
      if (not_chosen == 0)
      {
         printf("\n*** Choose the output matrix ***");
         Choose_letter_for_new(&letter_nr2, &not_chosen);
         if (not_chosen == 0)
         {
            //multiplying by scalar:
            //determine size of new matrix
            matrix[letter_nr2].owned=1;
            matrix[letter_nr2].sizea=matrix[letter_nr].sizea;
            matrix[letter_nr2].sizeb=matrix[letter_nr].sizeb;
            //multiply by scalar
            for (i=0;i<matrix[letter_nr2].sizea;i++)
            {
               for (j=0;j<matrix[letter_nr2].sizeb;j++)
               {
                  matrix[letter_nr2].values[i][j]=(matrix[letter_nr].values[i][j])*scalar;
               }
            }
            //show the matrix
            Show_matrix(letter_nr2);
         }
      }
      if (not_chosen != 0)
      {
         printf("\nYou have not created the scalar multiplication of matrices...");
      }
}

void Func_j() //Matrix multiplication (MxN)x(NxP)=(MxP)
{
   int letter_nr,letter_nr2,letter_nr3;
   int not_chosen;
   int i,j,k;
   float temp_sum;
   printf("[MATRIX MULTIPLICATION (MxN)x(NxP) = (MxP)]\n");
   Show_owned();
   printf("\n*** Choose the first matrix ***");
   Choose_letter(&letter_nr, &not_chosen);
   if (not_chosen == 0)
   {
      printf("\n*** Choose the second matrix ***");
      Choose_letter(&letter_nr2, &not_chosen);
      //check the conditions
      if (matrix[letter_nr].sizeb==matrix[letter_nr2].sizea)
      {
         printf("\nOrder of matrices is proper");
      }
      else
      {
         printf("\n!!!!! Second order of first matrix and first order of second matrix have to be \nequal !!!!!");
         not_chosen=1;
      }
      if (not_chosen == 0)
      {
         printf("\n*** Choose the outside matrix, which will contain the matrix multiplication ***");
         Choose_letter_for_new(&letter_nr3, &not_chosen);
         if (not_chosen == 0)
         {
            //addition:
            //determine size of new matrix
            matrix[letter_nr3].owned=1;
            matrix[letter_nr3].sizea=matrix[letter_nr].sizea;
            matrix[letter_nr3].sizeb=matrix[letter_nr2].sizeb;
            //add values
            for (i=0;i<matrix[letter_nr3].sizea;i++)
            {
               for (j=0;j<matrix[letter_nr3].sizeb;j++)
               {
                  //matrix[letter_nr3].values[i][j]=matrix[letter_nr].values[i][j]+matrix[letter_nr2].values[i][j];
                  temp_sum=0;
                  for (k=0;k<matrix[letter_nr].sizeb;k++) //k<n
                  {
                     temp_sum = temp_sum + (matrix[letter_nr].values[i][k] * matrix[letter_nr2].values[k][j]);
                  }
                  matrix[letter_nr3].values[i][j] = temp_sum;
               }
            }
            //show the matrix
            Show_matrix(letter_nr3);
         }
      }
   }
   if (not_chosen != 0)
   {
      printf("\nYou have not multiplied these matrices...");
   }
}

float Determine_the_proper_sequence(int * my_rows2[255])
{
   int i,j;
   int numbers[255];
   for (i=0;i<255;i++) //clear numbers[]
   {
      numbers[i]=0;
   }
   for (i=1;i<(*my_rows2[0]+1);i++) //fill numbers[]
   {
      numbers[*my_rows2[i]]=1;
   }
   j=1;
   for (i=255;i>0;i--) //fill my_rows2[]
   {
      if (numbers[i]==1) {*my_rows2[j]=i; j=j+1;}
   }
}

float Calculate_determinant(int letter_nr, int my_rows[255], int my_columns[255])
{
   int order;
   struct matrices local_matrix;
   int i,j;

   //rewrite chosen matrix as a local_matrix
   for (i=0;i<matrix[letter_nr].sizea;i++)
   {
      for (j=0;j<matrix[letter_nr].sizeb;j++)
      {
         local_matrix.values[i][j] = matrix[letter_nr].values[i][j];
      }
   }

   //delete some of rows
   if (my_rows[0]!=0)
   {
      //a - determine the proper sequence of rows to delete (3 1,3,2 => 3 3,2,1)
      Determine_the_proper_sequence(&my_rows);
      //b - delete these rows
   }


   //calculate the determinant
   order=matrix[letter_nr].sizea;
   switch (order)
   {
      case 1 : return local_matrix.values[0][0]; break;   //matrix[letter_nr] - local_matrix
      case 2 : return ((local_matrix.values[0][0]*local_matrix.values[1][1])-(local_matrix.values[1][0]*local_matrix.values[0][1])); break;
      default : return 12; break;
   }
}

void Func_l() //Determinant det[(MxM)]=c
{
   int letter_nr;
   int not_chosen;
   int i,j,k;
   float determinant;
   printf("[DETERMINANT det[(MxM)] = c]\n");
   Show_owned();
   printf("\n*** Choose the matrix which determinant you would like to calculate ***");
   Choose_letter(&letter_nr, &not_chosen);
   if (not_chosen == 0)
   {
      //check whether this is a square matrix
      if ((matrix[letter_nr].sizea==matrix[letter_nr].sizeb))
      {
         rows[0]=0;columns[0]=0;
         determinant = Calculate_determinant(letter_nr, rows, columns); //calculate the determinant
         printf("\nThis determinant is equal to: %f",determinant);
      }
      else
      {
         printf("\n!!! It must be the square matrix !!!");
      }
   }
   else
   {
      printf("\nYou have not calculated the determinant...");
   }
}

void Func_m() //Inverse (MxM)^(-1)=(MxM) if det[(MxM)]<>0
{
   int letter_nr,letter_nr2;
   int not_chosen;
   int i,j,k;
   float determinant;
   printf("[INVERSE (MxM)^(-1)=(MxM) if det[(MxM)]<>0\n");
   Show_owned();
   printf("\n*** Choose the matrix which inverse you would like to find ***");
   Choose_letter(&letter_nr, &not_chosen);
   if (not_chosen == 0)
   {
      //check whether this is a square matrix
      if ((matrix[letter_nr].sizea==matrix[letter_nr].sizeb))
      {
         rows[0]=0;columns[0]=0;
         determinant = Calculate_determinant(letter_nr, rows, columns); //calculate the determinant
         printf("\nThis determinant is equal to: %f",determinant);
         if (determinant != 0)
         {
            printf("\n*** Choose the output matrix for inverse matrix ***");
            Choose_letter_for_new(&letter_nr2, &not_chosen);
            if (not_chosen == 0)
            {
               printf("\nCalculatin' the inverse matrix is in progress...");
               //MAIN PART OF THE FUNCTION BEGINS HERE
               //determine size of new matrix
               matrix[letter_nr2].owned=1;
               matrix[letter_nr2].sizea=matrix[letter_nr].sizea;
               matrix[letter_nr2].sizeb=matrix[letter_nr].sizeb;
               //calculate the inverse matrix

               //show the matrix
               Show_matrix(letter_nr2);
            }
            else
            {
               not_chosen = 1;
            }
         }
         else
         {
            printf("!!! This matrix does not have an inverse matrix because det(M)=0 !!!");
         }
      }
      else
      {
         printf("\n!!! It must be the square matrix !!!");
      }
   }
   if (not_chosen != 0)
   {
      printf("\nYou have not found the inverse matrix...");
   }
}

int main(int argc, char *argv[])
{
   char chosen_opt;

   int i;

   //give the information that temporary matrices for calculating determinants are clear:
   //int rows[255], columns[255]; <= this specification is on the beginning of application
   rows[0]=0;columns[0]=0; //0th elements contain number of rows/columns to delete

   //give the information that there are no owned matrices:
   for (i=0;i<27;i++)
      matrix[i].owned=0;

   //prepare testing matrix
   matrix[20].owned=1;
   matrix[20].sizea=3;
   matrix[20].sizeb=2;
   matrix[20].values[0][0]=-1;
   matrix[20].values[0][1]=3;
   matrix[20].values[1][0]=4;
   matrix[20].values[1][1]=-2;
   matrix[20].values[2][0]=5;
   matrix[20].values[2][1]=0;
   matrix[21].owned=1;
   matrix[21].sizea=2;
   matrix[21].sizeb=2;
   matrix[21].values[0][0]=-3;
   matrix[21].values[0][1]=2;
   matrix[21].values[1][0]=-4;
   matrix[21].values[1][1]=1;
   matrix[22].owned=1;
   matrix[22].sizea=2;
   matrix[22].sizeb=4;
   matrix[22].values[0][0]=10;
   matrix[22].values[0][1]=10;
   matrix[22].values[0][2]=10;
   matrix[22].values[0][3]=10;
   matrix[22].values[1][0]=1000;
   matrix[22].values[1][1]=10;
   matrix[22].values[1][2]=100;
   matrix[22].values[1][3]=1;
   matrix[23].owned=1;
   matrix[23].sizea=1;
   matrix[23].sizeb=1;
   matrix[23].values[0][0]=100;
   matrix[24].owned=1;
   matrix[24].sizea=2;
   matrix[24].sizeb=2;
   matrix[24].values[0][0]=10;
   matrix[24].values[0][1]=20;
   matrix[24].values[1][0]=30;
   matrix[24].values[1][1]=40;
   matrix[25].owned=1;
   matrix[25].sizea=3;
   matrix[25].sizeb=3;
   matrix[25].values[0][0]=1;
   matrix[25].values[0][1]=2;
   matrix[25].values[0][2]=3;
   matrix[25].values[1][0]=4;
   matrix[25].values[1][1]=5;
   matrix[25].values[1][2]=6;
   matrix[25].values[2][0]=7;
   matrix[25].values[2][1]=8;
   matrix[25].values[2][2]=9;

   do     //choose the operation on matrix
   {
      chosen_opt = choose_opt();
      //printf("Your choice: %c\n",chosen_opt);
      switch (chosen_opt)
      {
         case 'a': Func_a(); break;
         case 'c': Func_c(); break;
         case 'd': Func_d(); break;
         case 'g': Func_g(); break;
         case 'h': Func_h(); break;
         case 'i': Func_i(); break;
         case 'j': Func_j(); break;
         case 'l': Func_l(); break;
         case 'm': Func_m(); break;
         //case 'm': printf("Now you own matrix nr7"); matrix[7].owned=1; break; //temporary option
         //case 'n': printf("You don't own m nr7"); matrix[7].owned=0; break;    //temporary option
         case 'n': printf("If you have any questions, e-mail: kawafis44@gmail.com"); break;
         case 'o': printf("See you later!"); break;
         case 'q': //temporary testing function
            printf("\n rows[0]=%d rows[1]=%d rows[2]=%d rows[3]=%d rows[4]=%d ",rows[0],rows[1],rows[2],rows[3],rows[4]);
            rows[0]=4; rows[1]=5; rows[2]=3; rows[3]=7; rows[4]=2;
            printf("\n rows[0]=%d rows[1]=%d rows[2]=%d rows[3]=%d rows[4]=%d ",rows[0],rows[1],rows[2],rows[3],rows[4]);
            Determine_the_proper_sequence(&rows); //TUTAJ POJAWIA SIE PROBLEM Z KOMPILACJA !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            printf("\n rows[0]=%d rows[1]=%d rows[2]=%d rows[3]=%d rows[4]=%d ",rows[0],rows[1],rows[2],rows[3],rows[4]);
            break;
         default : printf("Under construction"); break;
      }
      printf("\n");
      system("pause");
   } while (chosen_opt!='o');

   return 0;
} 
ODPOWIEDZ