Rabu, 13 April 2011

LISTING PROGRAM K-MAP



#include

#include

#include

#include

int a,b,c,d;

action ();

void main ()

{

char ch;

do

{

clrscr();

textcolor (BLACK+BLINK);

printf("\n\n\n\n\t\t\t");

cputs(" KARNAUG MAP EVALUATION ");

printf("\n\n\n\n\t\t A\\B");

printf("\n\t\t\t");

printf("|--------|\n");

printf("\t\t\t");

printf("| a | b |\n");

printf("\t\t\t");

printf("|--------|\n");

printf("\t\t\t");

printf("| c | d |\n");

printf("\t\t\t");

printf("|-------|\n");

printf("\n\n\n");

printf("ENTER A: \n\t");

scanf("%d",&a);

printf("ENTER B: \n\t");

scanf("%d",&b);

printf("ENTER C: \n\t");

scanf("%d",&c);

printf("ENTER D: \n\t");

scanf("%d",&d);

printf("\n");

printf("\n\n\n\t\t A\\B");

printf("\n");

printf("\t\t\t");

printf("|------------|\n");

printf("\t\t\t");

cout<<"|"<<<"|"<<<"|\n";< span=""><<"|"<<<"|\n";<>

printf("\t\t\t");

printf("|------------|\n");

printf("\t\t\t");

cout<<"|"<<<"|"<<<"|\n";< span=""><<"|"<<<"|\n";<>

printf("\t\t\t");

printf("|------------|\n");

printf("\t\t\t");

printf("\n\n\n\a\a");

textcolor (BLACK);

cputs("The Result is: ");

action();

printf("\n Mau lanjut ?(Y/N): ");

ch=getche();

textcolor(YELLOW);

}

while(ch=='y' || ch=='Y');

}

action()

{

if ((a==1 || a==0)&&(b==1 || b==0)&&(c==1 || c==0)&&(d==1 || d==0))//&&(e==1 ||e==0)&&(f==1 || f==0)&&(g==1 || g==0)&&(h==1 || h==0))

{

//1 base :

if (a==1&&b==0&&c==0&&d==0)

printf("A'B'");

else if (a==0&&b==1&&c==0&&d==0)

printf("A'B");

else if (a==0&&b==0&&c==1&&d==0)

printf("AB'");

else if (a==0&&b==0&&c==0&&d==1)

printf("AB");

// BASE 2 - 0 :

else if (a==1&&b==1&&c==0&&d==0)

printf("A'");

else if (a==1&&b==0&&c==1&&d==0)

printf("B'");

else if (a==1&&b==0&&c==0&&d==1)

printf("A'B'+AB");

//BASE 2 - 1 :

else if (a==0&&b==1&&c==1&&d==0)

printf("A'B+AB'");

else if (a==0&&b==1&&c==0&&d==1)

printf("B");

//BASE 2 - 2 :

else if (a==0&&b==0&&c==1&&d==1)

printf("A");

//BASE 3

else if (a==1&&b==1&&c==1&&d==0)

printf("A'B'+A'B+AB = A'+B'");

else if (a==0&&b==1&&c==1&&d==1)

printf("A'B+AB'+AB = A+B ");

else if (a==1&&b==1&&c==1&&d==1)

printf("A'B'+A'B+AB'+AB = 1");

else if (a==1&&b==1&&c==0&&d==1)

printf("A'B'+A'B+AB = A'+B");

else if (a==1&&b==0&&c==1&&d==1)

printf("A'B'+AB'+AB = A+B'");

}

else

{

printf("\t SAlah...");

getch();

}

return 0;

}

Tidak ada komentar:

Posting Komentar