home *** CD-ROM | disk | FTP | other *** search
/ Flop Magazin 37 / Flop_Magazin_37_1995_05_Raster_cs_Side_A.atr / part2.c < prev    next >
Text File  |  2023-02-26  |  2KB  |  1 lines

  1. /* NERVY - soubor PART2.C */¢#define OPENERR "Can't open '%s'!\n\n"¢¢extern int mati[10][10];¢extern char cisla[200][2][11];¢extern int mat,cisl;/* pointery na soubory */¢¢/*  vytvoreni matice  */¢¢int matice()¢{ int x,y,a;¢  char s[200];¢¢  printf("\n\tZapis matice mescu\n");¢  printf("\n   !!  POZOR  - pokracovani znici puvodni soubor  !!\n");¢  printf("\nStisk Y <RETURN> pro novy zapis (jinak navrat)\n");¢¢ gets(s);¢ if(!(s[0] =='y'||s[0] =='Y'))¢    return(0);¢ if(!(mat = copen("D:MATICE.DAT",'w')))¢  {¢   printf(OPENERR,"D:MATICE.DAT");¢   pauza();¢   return(-1);¢  }¢ printf("\n\tzadej matici po cislech (oddelene RETURN)\n");¢¢ for(y=0;y<4;y++)¢   for(x=0;x<4;x++)¢   { gets(s);¢     mati[x][y] = val(s);¢   }¢¢ for(y=0;y<10;y++)¢   for(x=0;x<10;x++)¢    { a=mati[x][y];¢      fprintf(mat,"%d\n",a);¢    }¢ cclose(mat);¢ return(1);¢}¢¢/* -  tvorba rodnych cisel   -- */¢int zad_cisla()¢{¢ printf("\n\tpouzij textovy editor v rezimu ASCII\n");¢ printf("\tjednotlive polozky oddeluj jako odstavce\n");¢ pauza();¢}¢¢/* - vypis obsahu mescu (matice) - */¢oprav()¢{ int x,y,i;¢¢  printf("\n\tVypis matice\n");¢  for(y=0;y<10;y++)¢  { for(x=0;x<10;x++)¢     { i =  mati[x][y];¢       printf("%d ",i);¢     }¢    printf("\n\n");¢  }¢  pauza();¢}¢¢/* ---    inicializace matice   -   */¢int int_mat()¢{ int x,y,b;¢  char s[15];¢¢ if((mat=copen("D1:MATICE.DAT",'r'))<0)¢  {¢   printf(OPENERR,"D:MATICE.DAT");¢   pauza();¢   return(-1);¢  }¢¢ for(y=0;y<10;y++)¢    for(x=0;x<10;x++)¢     { if(cgets(mat,s) != 1)¢        { printf ("\nDelka souboru je kratka ");¢          return(0);¢        }¢       mati[x][y]=val(s);¢     }¢¢ cclose(mat); ¢ return(1);¢}¢¢int cgets(pt,s)¢int pt;¢char s[];¢{ int i;¢  char c;¢¢  for(i=0;;i++)¢  { if((c=cgetc(pt))<0)¢      return(0);¢    s[i] = c;¢    if(c == '\n')¢     { s[i] = 0;¢       return(1);¢     }¢  }¢}¢