Guest User

Untitled

a guest
Apr 20th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 14.61 KB | None | 0 0
  1. /******************************************************
  2. ** Soubor:  proj3
  3. ** Datum:   2011/23/11
  4. ** Autor:   Vojtech Hrdina, xhrdin07@stud.fit.vutbr.cz
  5. ** Projekt: Iteracni vypocty, projekt c. 2 pro predmet IZP
  6. ** Popis:   Maticove operace
  7. ******************************************************/
  8.  
  9. // prace se vstupem vystupem
  10. #include <stdio.h>
  11.  
  12. // obecne funkce jazyka C
  13. #include <stdlib.h>
  14.  
  15. // matematicky funkce(pow,...)
  16. #include <math.h>
  17.  
  18. #include <string.h>
  19.  
  20. #define MYABS(x) ((x)<0 ? (-x) : (x))
  21.  
  22. #define ERRCPARAMS  -1
  23.  
  24. #define ERRCNULL    -2
  25.  
  26. #define ERRCALLOC   -3
  27.  
  28. #define ERRCFORM    -4
  29.  
  30. #define STVHELP     0
  31.  
  32. #define STVTEST     1
  33.  
  34. #define STVADD      2
  35.  
  36. #define STVMULT     3
  37.  
  38. #define STVTRANS    4
  39.  
  40. #define STVEXPR     5
  41.  
  42. #define STVCAROM    7
  43.  
  44. const char* ERRCMESSAGE[]=
  45. {
  46.  
  47. "Nespravne parametry",
  48.  
  49. "Soubor neexistuje",
  50.  
  51. "Alokace se nezdarila",
  52.  
  53. "Spatny format dat"
  54.  
  55. };
  56.  
  57.  
  58. typedef struct TMatrix
  59. {
  60.     int pocetradku;
  61.     int pocetsloupcu;
  62.     int **pole;
  63.     int error;
  64.     FILE* soubor;
  65.     int *radky;
  66. }TMatrix;
  67.  
  68. // funkce na parametry
  69. int loadparams(char **argc, int argv)
  70. {
  71.     // parametr pro otevreni napovedy
  72.     if(argv == 2 && (!strcmp(argc[1],"-h")))
  73.     {
  74.         return STVHELP;
  75.     }
  76.     // parametr TEST
  77.     else if(argv == 3 && (!strcmp(argc[1],"--test")))
  78.     {
  79.         return STVTEST;
  80.     }
  81.     // parametr pro operaci scitani
  82.     else if(argv == 4 && (!strcmp(argc[1],"--add")))
  83.     {
  84.         return STVADD;
  85.     }
  86.     // parametr pro operaci nasobeni
  87.     else if(argv == 4 && (!strcmp(argc[1],"--mult")))
  88.     {
  89.         return STVMULT;
  90.     }
  91.     // parametr pro operaci transpozici
  92.     else if(argv == 3 && (!strcmp(argc[1],"--trans")))
  93.     {
  94.         return STVTRANS;
  95.     }
  96.     // parametr pro operaci vyraz
  97.     else if(argv == 4 && (!strcmp(argc[1],"--expr")))
  98.     {
  99.         return STVEXPR;
  100.     }
  101.     // parametr pro operaci kulecnik
  102.     else if(argv == 7 && (!strcmp(argc[1],"--carom")))
  103.     {
  104.         return STVCAROM;
  105.     }
  106.  
  107.     else
  108.     {
  109.         return ERRCPARAMS;
  110.     }
  111. }
  112.  
  113. // funkce na otevreni souboru
  114. void openfile(char* jmeno, TMatrix *matice)
  115. {
  116.  
  117.     int Xradku;
  118.     int Ysloupcu;
  119.  
  120.     FILE* soubor;
  121.     soubor = fopen(jmeno,"r");
  122.    
  123.     if (soubor == NULL)
  124.     {
  125.         matice->error=ERRCNULL;
  126.         return;
  127.     }
  128.         // a nacteni poctu radku a sloupcu
  129.         if(fscanf (soubor,"%d %d", &Ysloupcu, &Xradku) != 2)
  130.         {
  131.             matice->error=ERRCFORM;
  132.         }
  133.  
  134.     matice->soubor=soubor;
  135.     matice->pocetsloupcu=Ysloupcu;
  136.     matice->pocetradku=Xradku;
  137.  
  138.     return;
  139. }
  140.  
  141. // alokace pameti
  142. void alokace(TMatrix * matice)
  143. {
  144.     int i; 
  145.  
  146.     matice->pole= (int** ) malloc (matice->pocetradku*sizeof (int *));
  147.    
  148.     if(matice->error == 0)
  149.     {
  150.         for (i = 0; i < matice-> pocetradku; i++)
  151.         {
  152.             matice->pole[i] = (int* ) malloc(matice->pocetsloupcu * sizeof(int));
  153.                
  154.                 if(matice->pole[i] == NULL)
  155.                 {     // pri chybe dealokuje pamet
  156.                     for(i = i - 1; i >= 0; i--)
  157.                     {
  158.                          free(matice->pole[i]);
  159.                     }
  160.                
  161.                     free(matice->pole);
  162.  
  163.                     matice->error=ERRCALLOC;
  164.                 }
  165.                
  166.                 else if(matice->error != 0)
  167.                 {
  168.                     break;
  169.                 }
  170.         }
  171.     }
  172.  
  173.     if(matice->pole == NULL)
  174.     {
  175.         matice->error= ERRCALLOC;
  176.     }
  177.  
  178.     return;
  179. }
  180.  
  181. // dealokace pameti
  182. void dealokace(TMatrix *matice)
  183. {
  184.     int i=0;
  185.  
  186.     while(i < matice->pocetradku)
  187.     {
  188.         free(matice->pole[i]);
  189.     }
  190.    
  191.     free(matice->pole);
  192.  
  193.     i++;
  194. }
  195.  
  196. // naplneni matice
  197. void fillmatice(TMatrix *matice)
  198. {
  199.     int j;
  200.     int i;
  201.     int k;
  202.  
  203.     for(j = 0; j < matice->pocetsloupcu; j++)
  204.     {
  205.         for(i = 0; i < matice->pocetradku; i++)
  206.         {  
  207.             // kontrola
  208.             if(fscanf(matice->soubor, "%d", &matice->pole[i][j]) != 1) 
  209.             {
  210.                 matice->error = ERRCFORM;
  211.                 return;
  212.             }
  213.         }
  214.  
  215.         // testovani konce souboru
  216.         if(fscanf(matice->soubor, "%d", &k) == 1)
  217.         {
  218.             matice->error = ERRCFORM;
  219.             return;
  220.         }
  221.     }
  222.    
  223.     return;
  224. }
  225.  
  226. // zarovnani
  227. void align(TMatrix *matice)
  228. {
  229.     int i;
  230.     int j;
  231.     int m;
  232.  
  233.     matice->radky = (int*) malloc(matice->pocetradku * (sizeof(int)));
  234.  
  235.     for(i = 0; i < matice->pocetradku; i++)
  236.     {
  237.         matice->radky[i] = 0;
  238.     }
  239.  
  240.     for(j = 0; j < matice->pocetsloupcu; j++)                                          
  241.     {  
  242.         for(i = 0; i < matice->pocetradku; i++)
  243.         {      
  244.             m = 0;
  245.    
  246.             if(matice->pole[i][j] == 0)
  247.             {
  248.                 m = 1;
  249.             }
  250.  
  251.             else
  252.                 {
  253.                 while(MYABS(matice->pole[i][j]) >= pow(10,m))  // z mat knihovny, umocnovani pow
  254.                     {
  255.                     m++;            
  256.                     }
  257.             }
  258.  
  259.                 if(matice->pole[i][j] < 0)
  260.                 {
  261.                 m++;
  262.             }
  263.  
  264.             else if(matice->radky[i] > m)
  265.             {
  266.                 matice->radky[i] = m;
  267.             }
  268.            
  269.         }
  270.     }
  271.     return;
  272. }
  273.  
  274. // vypis pole
  275. void view(TMatrix *matice)         
  276. {
  277.     int m;
  278.     int j;
  279.     int i;
  280.     int k;
  281.  
  282.     printf("%d %d\n", matice->pocetsloupcu, matice->pocetradku);
  283.     for(j = 0; j < matice->pocetsloupcu; j++)
  284.         {          
  285.             for(i = 0; i < matice->pocetradku; i++)
  286.             {  
  287.                 if(matice->pole[i][j] < 0)
  288.                 {
  289.                     m = matice->radky[i]-1;
  290.                 }
  291.            
  292.                 else
  293.                 {
  294.                 m = matice->radky[i];
  295.                 }
  296.            
  297.  
  298.                 if(matice->pole[i][j] == 0)
  299.                 {
  300.                     for(k = 0; k < m; k++)
  301.                     {
  302.                         printf(" ");
  303.                     }
  304.                 }
  305.            
  306.                 else
  307.  
  308.                 {
  309.                 if(i == 0)
  310.                 {
  311.                     m--;
  312.                 }
  313.                
  314.                 while(MYABS(matice->pole[i][j]) < pow(10,m))
  315.                     {
  316.                              m--;
  317.                          printf(" ");            
  318.                     }
  319.             }
  320.            
  321.             printf("%d", matice->pole[i][j]);  
  322.         }
  323.        
  324.         printf(" \n");
  325.     }
  326.     // dealokace
  327.     free(matice->radky);
  328.     return;
  329. }
  330.  
  331. // zavreni
  332. void close(TMatrix *matice)
  333. {
  334.     fclose(matice->soubor);
  335. }
  336.  
  337. // vypis chyb
  338. void printerror(int error)                                             
  339. {
  340.     fprintf(stderr,"%s\n",ERRCMESSAGE[-1-error]);
  341. }
  342.  
  343. // funkce na scitani
  344. void add(TMatrix *matA, TMatrix *matB, TMatrix *matResult)
  345. {
  346.     int j;
  347.     int i;
  348.  
  349.     {
  350.         for(j = 0;j < matA-> pocetsloupcu; j++)
  351.         {
  352.             for(i = 0; i < matA->pocetradku; i++)
  353.             {
  354.                 matResult->pole[i][j] = matA->pole[i][j] + matB->pole[i][j];
  355.             }
  356.         }
  357.     }  
  358.     return;
  359. }
  360.  
  361. // funkce MULT
  362. void mult(TMatrix *matA, TMatrix *matB, TMatrix *matResult)
  363. {  
  364.     int j;
  365.     int i;
  366.     int k;
  367.  
  368.     {
  369.         for(j = 0; j < matA->pocetsloupcu; j++)
  370.         {  
  371.             for(i = 0; i < matB->pocetradku; i++)
  372.             {
  373.                 matResult->pole[i][j] = 0;
  374.                 for(k = 0; k < matA->pocetradku; k++)
  375.                 {
  376.                     matResult->pole[i][j] = matResult->pole[i][j] + matA->pole[k][j] * matB->pole[i][k];
  377.                 }
  378.             }
  379.         }
  380.     }
  381.     return;
  382. }
  383.  
  384. // funkce transpozice
  385. void transpozice(TMatrix *matice, TMatrix *matResult)      
  386. {
  387.     int j;
  388.     int i;
  389.  
  390.     for(j = 0; j < matice->pocetsloupcu; j++)
  391.     {
  392.         for(i = 0; i < matice->pocetradku; i++)
  393.         {
  394.             matResult->pole[j][i] = matice->pole[i][j];
  395.         }
  396.     }
  397.     return;
  398. }
  399.  
  400. void carom(TMatrix *matice, int numberx, int numbery, char* smer, int power)
  401. {
  402.     int cesta1;
  403.     int cesta2;
  404.     int i;
  405.  
  406.     if(numberx > matice->pocetradku || numbery > matice->pocetsloupcu)
  407.     {
  408.         matice->error=ERRCPARAMS;
  409.     }
  410.    
  411.     else
  412.     {
  413.  
  414.         if(strcmp(smer, "V") == 0)                                         
  415.         {
  416.             cesta1 = -1;
  417.             cesta2 = 0;
  418.         }
  419.  
  420.         else if(strcmp(smer, "Z") == 0)
  421.         {
  422.             cesta1 = 1;
  423.             cesta2 = 0;
  424.         }
  425.  
  426.         else if(strcmp(smer, "JV")==0)
  427.         {
  428.             cesta1 = -1;
  429.             cesta2 = -1;
  430.         }
  431.            
  432.         else if(strcmp(smer, "JZ") == 0)
  433.         {
  434.             cesta1 =  1;
  435.             cesta2 = -1;
  436.         }
  437.            
  438.         else if(strcmp(smer, "SV")==0)
  439.         {
  440.             cesta1 = -1;
  441.             cesta2 =  1;
  442.         }
  443.            
  444.         else if(strcmp(smer, "SZ") == 0)
  445.         {
  446.             cesta1 = 1;
  447.             cesta2 = 1;
  448.         }
  449.  
  450.         else
  451.         {
  452.             matice->error = ERRCPARAMS;
  453.         }
  454.  
  455.         if(matice->error == 0)
  456.         {
  457.             int posx = cesta1;
  458.             int posy = cesta2;
  459.  
  460.            
  461.             for(i = 0; i < power; i++)
  462.             {
  463.                 printf("%d ",matice->pole[posx][posy]);
  464.  
  465.                 // odraz koule
  466.                 if(posy + cesta2 < 0 || posy + cesta2 >= matice->pocetsloupcu) 
  467.                 {
  468.                     cesta2 = cesta2 * (-1);
  469.                 }
  470.                
  471.                 if(posx + cesta1 < 0 || posx + cesta1 >= matice->pocetradku)
  472.                 {
  473.                     cesta1 = cesta1 * (-1);
  474.                 }
  475.                
  476.                 // pri zmene sudyho / lichyho cisla se pricitava +-1 pro Xovej
  477.                 if(cesta1 == 1 && posy %2 == 0 && cesta2 !=0)      {}  
  478.                 else if(cesta1 == -1 && posy %2 == 1 &&cesta2 !=0) {}
  479.  
  480.                 else
  481.                 {
  482.                     posx = posx + cesta1;
  483.                 }
  484.                 posy = posy + cesta2;
  485.             }
  486.             printf("\n");
  487.         }
  488.            
  489.            
  490.     }
  491.     return;
  492. }
  493.  
  494. void help()
  495. {
  496.     printf(
  497.                     "autor Vojtech Hrdina, student FIT\n"
  498.                         "Program pracujici s maticemi.\n"
  499.  
  500.                     "zadani s parametry \n"
  501.                     "   -h  pro napovedu\n"
  502.                     "   --add  pro soucet matice.txt a matice2.txt\n"
  503.                     "   --mult  pro soucin matice.txt a matice2.txt\n"
  504.                     "   --trans  pro transpozici matice.txt\n"
  505.                     "   --expr  pro vyraz (A*BT+A) \n"
  506.                     "   --carom  kulecnikova koule\n");
  507. }
  508.  
  509.  
  510.  
  511. int main(int argv,char **argc)          
  512. {
  513.     int para1 = loadparams(argc,argv);
  514.  
  515.     if(para1 == ERRCPARAMS)
  516.     {
  517.         printerror(para1);
  518.     }
  519.  
  520.     else
  521.     {
  522.         TMatrix matice, matA, matB, matResult;
  523.         matice.error = 0;
  524.    
  525.         switch(para1)
  526.         {
  527.             case(STVHELP):
  528.             break;   // navrati false
  529.        
  530.             // test    
  531.             case(STVTEST): 
  532.             // soubor se otevre                
  533.             openfile(argc[2], &matice);
  534.        
  535.             if(matice.error == 0)                                                  
  536.             {
  537.                 // naolokuje
  538.                 alokace( &matice);
  539.             }
  540.    
  541.             if(matice.error==0)                                        
  542.             {
  543.                 // naplni
  544.                 fillmatice( &matice);  
  545.             }          
  546.  
  547.             if(matice.error==0)
  548.             {
  549.                 //  zavre
  550.                 close( &matice);
  551.                 // zarovna                 
  552.                 align( &matice);
  553.                 // a vypise            
  554.                 view( &matice);                
  555.             }
  556.                    
  557.             if(matice.error!=ERRCALLOC)
  558.             {
  559.                 // uvolni pamet
  560.                 dealokace( &matice);   
  561.             }
  562.             if(matice.error!=0)
  563.             {
  564.                 // i to by mohlo nstat
  565.                 printerror(matice.error);
  566.             }
  567.             break;
  568.  
  569.             // scitani
  570.                 case(STVADD):  
  571.                 matA.error=0;
  572.             matB.error=0;
  573.                 matResult.error=0;
  574.             openfile(argc[2], &matA);
  575.             if(matA.error==0)
  576.             {
  577.                 alokace( &matA);
  578.             }
  579.  
  580.             if(matA.error==0)
  581.             {
  582.                 fillmatice( &matA);
  583.                 close( &matB);
  584.             }
  585.  
  586.             if(matA.error!=0)
  587.             {
  588.             fprintf(stderr,"Matice A:");
  589.             printerror(matA.error);
  590.             }
  591.  
  592.             else
  593.             {
  594.             openfile(argc[3], &matB);
  595.             if(matB.error==0)
  596.             {
  597.                 alokace( &matB);
  598.             }
  599.  
  600.             if(matB.error==0)
  601.             {
  602.                 fillmatice( &matB);
  603.                 close( &matB);
  604.             }
  605.             if(matB.error!=0)
  606.             {
  607.                 fprintf(stderr,"Matice B:");
  608.                 printerror(matB.error);
  609.             }
  610.  
  611.             else
  612.             {  
  613.                 if(matA.pocetradku == matB.pocetradku && matA.pocetsloupcu == matB.pocetsloupcu)
  614.                 {
  615.                 matResult.pocetradku=matA.pocetradku;
  616.                 matResult.pocetsloupcu=matA.pocetsloupcu;
  617.                 alokace( &matResult);
  618.    
  619.                     if(matResult.error==0)
  620.                     {
  621.                         add(&matA,&matB,&matResult);
  622.                         align(&matResult);
  623.                         view(&matResult);
  624.                    
  625.                         if(matResult.error!=ERRCALLOC)
  626.                         {
  627.                             dealokace( &matResult);
  628.                         }
  629.                     }
  630.                 }
  631.  
  632.                 else
  633.                 {
  634.                     matResult.error=ERRCFORM;
  635.                     printerror(matResult.error);
  636.                 }
  637.             }
  638.  
  639.             if(matB.error!=ERRCALLOC)
  640.             {
  641.                 dealokace(&matB);
  642.             }
  643.         }
  644.  
  645.         if(matA.error!=ERRCALLOC)
  646.         {
  647.             dealokace (&matA);
  648.         }
  649.         break;
  650.  
  651.         // nasobeni
  652.         case(STVMULT):
  653.         matA.error=0;
  654.         matB.error=0;
  655.         matResult.error=0;
  656.         openfile(argc[2],&matA);
  657.  
  658.         if(matA.error==0)
  659.         {
  660.             alokace(&matA);
  661.         }
  662.  
  663.         if(matA.error==0)
  664.         {
  665.             fillmatice(&matA);
  666.             close(&matA);
  667.         }
  668.  
  669.         if(matA.error!=0)
  670.         {
  671.             fprintf(stderr,"Matice B:");
  672.             printerror(matA.error);
  673.         }
  674.  
  675.         else
  676.         {
  677.             openfile(argc[3],&matB);
  678.  
  679.             if(matB.error==0)
  680.             {
  681.             alokace(&matB);
  682.             }
  683.  
  684.             if(matB.error==0)
  685.             {
  686.                 fillmatice(&matB);
  687.                 close(&matB);
  688.             }
  689.  
  690.             if(matB.error!=0)
  691.             {
  692.                 fprintf(stderr,"Matice B:");
  693.                 printerror(matB.error);
  694.             }
  695.  
  696.             else
  697.             {  
  698.                 if(matA.pocetradku==matB.pocetsloupcu)
  699.                 {
  700.                     matResult.pocetradku=matA.pocetsloupcu;
  701.                     matResult.pocetradku=matB.pocetradku;
  702.                     alokace(&matResult);
  703.  
  704.                     if(matResult.error==0)
  705.                     {
  706.                         mult(&matA,&matB,&matResult);
  707.                         align(&matResult);
  708.                         view(&matResult);
  709.  
  710.                         if(matResult.error!=ERRCALLOC)
  711.                         {
  712.                         dealokace(&matResult);
  713.                         }
  714.                     }
  715.                 }
  716.  
  717.                 else
  718.                 {
  719.                     matResult.error=ERRCFORM;
  720.                     printerror(matResult.error);
  721.                 }
  722.             }
  723.  
  724.             if(matB.error!=ERRCNULL)
  725.             {
  726.                 dealokace( &matB);
  727.             }
  728.         }
  729.         if(matA.error!=ERRCALLOC)
  730.         {
  731.             dealokace(&matA);
  732.         }
  733.         break;
  734.  
  735.         // transpozice  pracuje se 2 poli
  736.         case(STVTRANS):
  737.         matice.error=0;
  738.         matResult.error=0;
  739.         openfile(argc[2],&matice);
  740.         if(matice.error==0)
  741.         {
  742.             alokace(&matice);
  743.         }
  744.  
  745.         if(matice.error==0)
  746.         {
  747.             fillmatice(&matice);
  748.             close(&matice);
  749.         }
  750.  
  751.         if(matice.error==0)
  752.         {
  753.             matResult.pocetradku=matice.pocetsloupcu;
  754.             matResult.pocetsloupcu=matice.pocetradku;
  755.             alokace(&matResult);
  756.  
  757.             if(matResult.error==0)
  758.             {
  759.                 transpozice(&matice,&matResult);
  760.                 align(&matResult);
  761.                 view(&matResult);
  762.                 dealokace(&matResult);
  763.             }
  764.         }
  765.        
  766.             if(matice.error!=ERRCALLOC)
  767.             {
  768.                 dealokace(&matice);
  769.             }
  770.  
  771.             if(matResult.error!=0)
  772.             {
  773.                 printerror(matResult.error);
  774.             }
  775.                   break;
  776.         // vyraz
  777.         case(STVEXPR):
  778.             matA.error=0;
  779.             matB.error=0;
  780.             matResult.error=0;
  781.    
  782.             openfile(argc[2],&matA);
  783.             if(matA.error==0)
  784.             alokace(&matA);
  785.             if(matA.error==0)
  786.             {
  787.                 fillmatice(&matA);
  788.                 close(&matA);
  789.             }
  790.             if(matA.error!=0)
  791.             {  
  792.                 printerror(matA.error);
  793.             }
  794.             else
  795.             {      
  796.             openfile(argc[3],&matB);
  797.             if(matB.error==0)
  798.             alokace(&matB);
  799.             if(matB.error==0)
  800.             {
  801.                 fillmatice(&matB);
  802.                 close(&matB);
  803.             }
  804.             if(matB.error!=0)
  805.             {
  806.                 printerror(matB.error);
  807.             }
  808.    
  809.             else if(matA.pocetradku==matB.pocetradku&&matB.pocetradku==matB.pocetsloupcu)
  810.             {      
  811.                 matResult.pocetsloupcu=matB.pocetradku;
  812.                 matResult.pocetradku=matB.pocetsloupcu;
  813.                 alokace(&matResult);
  814.  
  815.                 if(matResult.error==0)
  816.                 {
  817.                     transpozice(&matB,&matResult);
  818.                     dealokace(&matB);  
  819.                     matB.pocetsloupcu=matA.pocetsloupcu;
  820.                     matB.pocetradku=matResult.pocetradku;
  821.                     alokace(&matB);
  822.                 }
  823.  
  824.                 if(matB.error!=0)
  825.                 {
  826.                     printerror(matB.error);
  827.                 }
  828.  
  829.                 else
  830.                 {      
  831.                     mult(&matA,&matResult,&matB);
  832.                     dealokace(&matResult);
  833.                     matResult.pocetradku=matA.pocetradku;
  834.                     matResult.pocetsloupcu=matA.pocetsloupcu;
  835.                     alokace(&matResult);
  836.  
  837.                     if(matResult.error==0)
  838.                     {
  839.                         add(&matA,&matB,&matResult);
  840.                         align(&matResult);
  841.                         view(&matResult);
  842.                         dealokace(&matResult);
  843.                     }
  844.  
  845.                     else
  846.                     {  
  847.                         printerror(matResult.error);
  848.                     }
  849.                 }          
  850.             }
  851.  
  852.             if(matB.error!=ERRCALLOC)
  853.             {
  854.                 dealokace(&matB);
  855.             }
  856.  
  857.         }
  858.    
  859.         if(matA.error!=ERRCALLOC)
  860.         {
  861.             dealokace(&matA);
  862.         }
  863.         break;
  864.            
  865.         case(STVCAROM):
  866.         openfile(argc[6],&matice);
  867.         if(matice.error==0)
  868.         {
  869.             alokace(&matice);
  870.         }
  871.  
  872.         if(matice.error==0)
  873.         {
  874.             fillmatice(&matice);
  875.             close(&matice);
  876.         }
  877.  
  878.         if(matice.error==0)
  879.         {
  880.             carom(&matice,atoi(argc[2]),atoi(argc[3]),argc[4],atoi(argc[5]));
  881.         }
  882.  
  883.         if(matice.error!=ERRCALLOC)
  884.         {
  885.             dealokace(&matice);
  886.         }
  887.  
  888.         if(matice.error!=0)
  889.         {
  890.             printerror(matice.error);
  891.         }
  892.  
  893.         break;
  894.         }
  895.        
  896.     }
  897.     return 0;
  898. }
Add Comment
Please, Sign In to add comment