This thesis contains program coding module for generation logics test by Boolean gap

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: Programs in C, C++

Program: Prac_ndf.cBooldif.zip
File exe: Booldif.exe
need: Adresar.cColor.cDerivac.cError.cFunkcie.cHelp.cKey.cLine_edi.cMain.cMenu.cObsluha.cOkno.cPrac_ndf.cSlovnik.cSlov_fon.cStatist.cUtil.cVideo.cVystupy.cAdresar.hColor.hDefine.hError.hFunkcie.hGlob.hKey.hLine_edi.hMbooldif.hMenu.hOkno.hSlov_fon.hUtil.hVideo.h
Example: Example.zipBin_10_o.ndfBin_10_o.ndfBin_1and.ndfBin_2rad.ndfBin_3rad.ndfBin_4rad.ndfHard.ndfI_reg_lo.ndfReg_jk.ndfScitac_s.ndfScp_1rad.ndfScp_2rad.ndfScp_2r_1.ndfScp_3rad.ndfScp_4r_2.ndfScp_6r_3.ndfScp_8r_4.ndfSc_1r_pj.ndfSc_1r_sj.ndfSc_1_aoi.ndfSc_2r_4.ndfSc_3r_6.ndfSc_7400n.ndfSc_aon.ndfSimp3_a.ndfSimp3_b.ndfSimp4_a.ndfSimp4_b.ndfSimp4_c.ndfSimp6_a.ndfTest_vod.ndfZle.ndf
Manual: Prirucky.zip

This thesis contains program coding module for generation logics test by Boolean gap. Compile vector of fault for existent circuit, forth about all boughs herself chauffeur. Results is absolute gauge. Program application enables four modes It is implemented in the C programming language for the operating system MS-DOS, or another compatible with it. The program is suitable for an interactive way to communicate with the user, allowing a comfortable working environment are similar to Turbo Vision.
//************************************************************************//
// DERIVAC.C                                                              //
// Derivacia funkcie podle zadannej funkcie                               //
//                                                                        //
//                                                              2.9.1997  //
//************************************************************************//
#include "mbooldif.h"
#include "glob.h"
#include "util.h"
 
//************************************************************************//
// Pripravy derivaciu podla premennej vysledok rozklada do K,K0,K1        //
//                                                              2.9.1997  //
//************************************************************************//
int derivac_dF(zapis_NDF *h_fnc, int prem, zapis_NDF *K, zapis_NDF *K0, zapis_NDF *K1)
{
int i;					// devcica
char nadpis[80];
					// taku premennu nemam
 znuluj(K,1);znuluj(K1,1);znuluj(K0,1);
 if (( prem >= h_fnc->pv_NDF ) || ( prem < 0 )) return(FALSE);
 
 K->pv_NDF=h_fnc->pv_NDF;
 K0->pv_NDF=h_fnc->pv_NDF;
 K1->pv_NDF=h_fnc->pv_NDF;
 
 for (i=1; i<=h_fnc->poc_NDF; i++) {
 
     if ( h_fnc->pNDF[i][prem] == nic ) {	// Neobsahuje prem vobec
	 dalsie_NDF( K,0 );
	 strcpy( K->pNDF[ K->poc_NDF ], h_fnc->pNDF[i] );
	 K->pNDF[ K->poc_NDF ][ prem ]=nic;
	}
					       // Obsahuje a,b,c
     if ( h_fnc->pNDF[i][prem] == jclen ) {
	 dalsie_NDF( K1,0 );
	 strcpy( K1->pNDF[ K1->poc_NDF ], h_fnc->pNDF[i] );
	 K1->pNDF[ K1->poc_NDF ][ prem ]=nic;
	}
					       // Obsahuje A,B,C
     if ( h_fnc->pNDF[i][prem] == nclen ) {
	 dalsie_NDF( K0,0 );
	 strcpy( K0->pNDF[ K0->poc_NDF ], h_fnc->pNDF[i] );
	 K0->pNDF[ K0->poc_NDF ][ prem ]=nic;
	}
    }	// end for(i=1;
 
    sprintf( nadpis,"\n dF/d%s = ú(úűKü+Kűúü)\n ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n K = ", index );
 
    uloz_NDF( K, nadpis, TmpSubor[3] );
    uloz_NDF( K0, " Kü= ", TmpSubor[3] );
    uloz_NDF( K1, " Kű= ", TmpSubor[3] );
 
 return(TRUE);
}
 
//************************************************************************//
// Robi negaciu znaku nclen->jclen a naopak                               //
//                                                              3.9.1997  //
//************************************************************************//
char neguj( char clen )
{
 if ( clen == nclen ) return( jclen );
 if ( clen == jclen ) return( nclen );
 return( clen );
}
 
//************************************************************************//
// Podla toho aka pozicia vyrobi z neho znak a,b,c alebo A,B,C            //
//                                                              3.9.1997  //
//************************************************************************//
char bool_znak( char clen, int pozic )
{
 if ( clen == jclen ) return( 'a'+pozic );
 if ( clen == nclen ) return( 'ŕ'+pozic );
 return(' ');
}
 
//************************************************************************//
// toto je pre K negacia vztahu (ab+cd) = (A+B)(C+D)                      //
// z toho tazim a tak to robim                                            //
//                                                              3.9.1997  //
//************************************************************************//
char *K_negovane( zapis_NDF *K )
{
int x,y;
char deriv_ret[max_ret];
char pom[max_ret];
 
 strcpy( deriv_ret, "(" );
 for (y=1; y<=K->poc_NDF; y++ ) {
     strcat( deriv_ret, "(");
 
     for (x=0; x<K->pv_NDF; x++ )		// je to a,b,c alebo A,B,C
	 if (( K->pNDF[y][x] == jclen ) || ( K->pNDF[y][x] == nclen )) {
	    strchar( deriv_ret, bool_znak( neguj( K->pNDF[y][x] ), x ) );
	    strchar( deriv_ret, '+' );
	   } // end for(x=1; x<=
 
    if ( deriv_ret[ strlen( deriv_ret ) -1 ] == '+' )
	 strdel( deriv_ret, strlen( deriv_ret ) -1 );
 
    strchar( deriv_ret, ')' );
   } // end for(y=1;y<=K
 
 strchar( deriv_ret, ')' );
 
 strcpy( pom, deriv_ret );
 odstran_zatvorky( pom,1 );
 // negujem nic takze ma vzniknut 1
 if( strlen( pom ) == 0 ) {
    strcpy( deriv_ret, "(" );
    // bol to clen v ktorom sa nachadzala len premenna podla ktorej sa derivovalo
    if( K->poc_NDF != 0 ) strcat( deriv_ret, vstup_0 );
                     // tu nebolo nic
                     else strcat( deriv_ret, vstup_1 );
    strcat( deriv_ret, ")" );
   }
 
 return( deriv_ret );
}
 
//************************************************************************//
// Sucin clenov                                                           //
//                                                              3.9.1997  //
//************************************************************************//
char *K_sucin( zapis_NDF *K )
{
int x,y;
char deriv_ret[max_ret];
char pom[max_ret];
 
 strcpy( deriv_ret, "(" );
 for (y=1; y<=K->poc_NDF; y++ ) {
 
     for (x=0; x<K->pv_NDF; x++ )		// je to a,b,c alebo A,B,C
	 if (( K->pNDF[y][x] == jclen ) || ( K->pNDF[y][x] == nclen ))
	    strchar( deriv_ret, bool_znak( K->pNDF[y][x], x ) );
 
     strchar( deriv_ret, '+' );
     }
 
    if ( deriv_ret[ strlen( deriv_ret ) -1 ] == '+' )
	 strdel( deriv_ret, strlen( deriv_ret ) -1 );
 
 // chce nasobit nicim
 strchar( deriv_ret, ')' );
 
 strcpy( pom, deriv_ret );
 odstran_zatvorky( pom,1 );
 // nasobim nicim takze ma vzniknut 0
 if( strlen( pom ) == 0 ) {
    strcpy( deriv_ret, "(" );
    // bol to clen v ktorom sa nachadzala len premenna podla ktorej sa derivovalo
    if( K->poc_NDF != 0 ) strcat( deriv_ret, vstup_1 );
                     // tu nebolo nic
                     else strcat( deriv_ret, vstup_0 );
    strcat( deriv_ret, ")" );
   }
 
 return( deriv_ret );
}
 
//************************************************************************//
// Vysledkom tejto srandy by mala byt derivacia podla premennej           //
//                                                              3.9.1997  //
//************************************************************************//
char *zderivuj_dF( zapis_NDF *K, zapis_NDF *K0, zapis_NDF *K1 )
{
char deriv_ret[max_ret];
FILE *tmp,*fopen();
 
 if (( Rezim == VYUK ) || ( Rezim == PREV))
    tmp=fopen( strspoj( temp,TmpSubor[5]) ,"a+t" );// zapisuj inam, aby uzivatel nevidel
   else
    tmp=fopen( strspoj( temp,TmpSubor[3]) ,"a+t" );
 
 // ak je to pre premennu ktora nieje vo f(), vtedy je K0={} K1={}
 // blbost co ?, aj to sa stava
 if ( ( K1->poc_NDF == 0 ) && ( K0->poc_NDF == 0 ) && ( K->poc_NDF == 0 ) ) {
    deriv_ret[0]='\0';
    fprintf(tmp,"\n");
    fprintf(tmp,"\n dF = {}\n\r");
    fclose(tmp);
    return( deriv_ret );
   }
 
 strcpy( deriv_ret, K_negovane(K) );	// df()= Kneg
 fprintf(tmp,"\n");
 fprintf(tmp,"\n ú            = %s", deriv_ret );
 
 strcat( deriv_ret, " ( " );		// df()= Kneg(
 
 strcat( deriv_ret, K_negovane(K1) );	// df()= Kneg( K1neg
 fprintf(tmp,"\n ú(úű         = %s", deriv_ret );
 
 strcat( deriv_ret, " " );		// dame medzeru
 strcat( deriv_ret, K_sucin(K0) );	// df()= Kneg( K1neg K0
 fprintf(tmp,"\n ú(úűKü       = %s", deriv_ret );
 
 strcat( deriv_ret, " + " );		// df()= Kneg( K1neg K0 +
 
 strcat( deriv_ret, K_sucin(K1) );	// df()= Kneg( K1neg K0 + K1
 fprintf(tmp,"\n ú(úűKü+Kű    = %s", deriv_ret );
 
 strcat( deriv_ret, " " );		// dame medzeru
 strcat( deriv_ret, K_negovane(K0) );	// df()= Kneg( K1neg K0 + K1 K0neg
 strcat( deriv_ret, " )" );		// df()= Kneg( K1neg K0 + K1 K0neg )
 fprintf(tmp,"\n ú(úűKü+Kűúü) = %s", deriv_ret );
 
 fclose(tmp);
 return( deriv_ret );
}
 
/*---------------------------------END--------------------------------------*/