answersLogoWhite

0

Code of K'maps i n C plus plus?

Updated: 10/25/2022
User Avatar

Wiki User

11y ago

Best Answer

#include<iostream>

#include<string.h>

//#include<graphics.h>

//#include<dos.h>

#include<math.h>

using namespace std;

int main()

{

// clrscr();

int c=1,c1=4,c2=1,c3=1,r[2000][10],c4=1,c5=1,p[2000][10],q[2000][10],o[2000][10],t[2000][10],s[2000][10],w[2000][10],i,l=1,j,k,m,u[2000][10],a[2000][10],v,e=0,g=1,f=1,h=0,b[2000][10],z[2000][10],y[6000][5],x[2000][10];

cout<<"Enter 0 for not selecting and 1 for selecting\n";

for(i=0;i<=15;i++)

{

cout<<"Enter the value for "<<i<<":";

cin>>v;

if(v==1)

{

a[c][5]=i;

m=i;

while(c1!=0)

{

a[c][c1]=m%2;

m=m/2;

c1--;

}

c++;

c1=4;

}

}

for(i=1;i<c;i++)

{

for(j=1;j<c;j++)

{

for(k=1;k<=4;k++)

{

if(a[i][k]+a[j][k]==1)

e++;

}

if(e==1)

{

for(k=1;k<=4;k++)

{

if(a[i][k]+a[j][k]!=1)

b[f][g]=a[i][k];

else

b[f][g]=3;

g++;

}

b[f][5]=a[i][5];

b[f][6]=a[j][5];

g=1;

f++;

h++;

}

e=0;

}

if(h==0)

{

for(k=1;k<=4;k++)

x[c2][k]=a[i][k];

c2++;

}

h=0;

}

c=0;

for(i=1;i<f;i++)

{

for(j=1;j<i;j++)

{

for(k=1;k<=4;k++)

{

if(b[i][k]==b[j][k])

c++;

}

if(c!=4)

e++;

c=0;

}

if(e==i-1)

{

for(k=1;k<=6;k++)

u[h+1][k]=b[i][k];

h++;

}

e=0;

}

for(i=1;i<=h;i++)

{

if(u[i][7]!=4)

{

for(j=1;j<=h;j++)

{

if(u[j][7]!=4)

{

if((u[i][6]==u[j][5])(u[i][6]==u[j][5])(u[i][5]==u[j][5])(u[i][5]==u[j][6]))

{

for(k=1;k<=h;k++)

{

if(u[j][6]==u[k][5]u[j][6]==u[k][6]u[j][5]==u[k][5]u[j][5]==u[k][6])

{

for(e=1;e<=h;e++)

{

if(i!=j&&i!=k&&i!=e&&j!=k&&j!=e&&k!=e)

{

if(u[k][6]!=u[e][5]&&u[k][6]!=u[e][6]&&u[k][6]!=u[e][6]&&u[k][6]!=u[e][5])

u[j][7]=4;

}

}

}

}

}

}

}

}

}

cout<<endl;

f=h+1;

e=0;h=0;g=1;l=1;c=1;

for(i=1;i<f;i++)

{

for(j=1;j<f;j++)

{

for(k=1;k<=4;k++)

{

if(u[i][k]+u[j][k]==1)

e++;

if((u[i][k]+u[j][k]==3)(u[i][k]+u[j][k]==4))

e=2;

}

if(e==1)

{

for(k=1;k<=4;k++)

{

if(u[i][k]+u[j][k]!=1&&u[i][k]+u[j][k]!=6)

z[l][g]=u[i][k];

else

z[l][g]=3;

g++;

}

g=1;

l++;

h++;

}

e=0;

}

if(h==0)

{

for(k=1;k<=7;k++)

w[c3][k]=u[i][k];

c3++;

}

h=0;

}

c=0;

for(i=1;i<l;i++)

{

for(j=1;j<i;j++)

{

for(k=1;k<=4;k++)

{

if(z[i][k]==z[j][k])

c++;

}

if(c!=4)

e++;

c=0;

}

if(e==i-1)

{

for(k=1;k<=4;k++)

t[h+1][k]=z[i][k];

h++;

}

e=0;

}

l=h+1;

e=0;h=0;g=1;m=1;c=1;c1=4;

for(i=1;i<l;i++)

{

for(j=i+1;j<l;j++)

{

for(k=1;k<=4;k++)

{

if(t[i][k]+t[j][k]==1)

e++;

if(t[i][k]+t[j][k]==3t[i][k]+t[j][k]==4)

e=2;

}

if(e==1)

{

for(k=1;k<=4;k++)

{

if(t[i][k]+t[j][k]!=1&&t[i][k]+t[j][k]!=6)

y[m][g]=t[i][k];

else

y[m][g]=3;

g++;

}

g=1;

m++;

h++;

}

e=0;

}

if(h==0)

{

for(k=1;k<=4;k++)

r[c4][k]=t[i][k];

c4++;

}

h=0;

}

c=0;h=0;

for(i=1;i<m;i++)

{

for(j=1;j<i;j++)

{

for(k=1;k<=4;k++)

{

if(y[i][k]==y[j][k])

c++;

}

if(c!=4)

e++;

c=0;

}

if(e==i-1)

{

for(k=1;k<=4;k++)

s[h+1][k]=y[i][k];

h++;

}

e=0;

}

f=h+1;

e=0;h=0;g=1;l=1;c=1;

for(i=1;i<f;i++)

{

for(j=1;j<f;j++)

{

for(k=1;k<=4;k++)

{

if(s[i][k]+s[j][k]==1)

e++;

if((s[i][k]+s[j][k]==3)(s[i][k]+s[j][k]==4))

e=2;

}

if(e==1)

{

for(k=1;k<=4;k++)

{

if(s[i][k]+s[j][k]!=1&&s[i][k]+s[j][k]!=6)

q[l][g]=s[i][k];

else

q[l][g]=3;

g++;

}

g=1;

l++;

h++;

}

e=0;

}

if(h==0)

{

for(k=1;k<=4;k++)

p[c5][k]=s[i][k];

c5++;

}

h=0;

}

c=0;

for(i=1;i<l;i++)

{

for(j=1;j<i;j++)

{

for(k=1;k<=4;k++)

{

if(q[i][k]==q[j][k])

c++;

}

if(c!=4)

e++;

c=0;

}

if(e==i-1)

{

for(k=1;k<=4;k++)

o[h+1][k]=q[i][k];

h++;

}

e=0;

}

for(i=1;i<=h;i++)

{

cout<<1;

}

cout<<endl;

for(i=1;i<c2;i++)

{

if(x[i][1]==0)

cout<<"A'";

if(x[i][1]==1)

cout<<"A";

if(x[i][2]==0)

cout<<"B'";

if(x[i][2]==1)

cout<<"B";

if(x[i][3]==0)

cout<<"C'";

if(x[i][3]==1)

cout<<"C";

if(x[i][4]==0)

cout<<"D'";

if(x[i][4]==1)

cout<<"D";

cout<<"+";

}

c=0;

for(i=1;i<c3;i++)

{

if(w[i][7]!=4)

{

if(w[i][1]==0)

cout<<"A'";

if(w[i][1]==1)

cout<<"A";

if(w[i][2]==0)

cout<<"B'";

if(w[i][2]==1)

cout<<"B";

if(w[i][3]==0)

cout<<"C'";

if(w[i][3]==1)

cout<<"C";

if(w[i][4]==0)

cout<<"D'";

if(w[i][4]==1)

cout<<"D";

cout<<"+";

}

}

cout<<endl;

c=0;

for(i=1;i<c4;i++)

{

for(j=1;j<=h;j++)

{

if(((o[j][1]-r[i][1])==2(o[j][1]-r[i][1])==3(o[j][1]-r[i][1])==0)&&((o[j][2]-r[i][2])==2(o[j][2]-r[i][2])==3(o[j][2]-r[i][2])==0)&&((o[j][3]-r[i][3])==2(o[j][3]-r[i][3])==0(o[j][3]-r[i][3])==3)&&((o[j][4]-r[i][4])==2(o[j][4]-r[i][4])==0(o[j][4]-r[i][4])==3))

c++;

}

for(j=1;j<c5;j++)

{

if(((p[j][1]-r[i][1])==2(p[j][1]-r[i][1])==3(p[j][1]-r[i][1])==0)&&((p[j][2]-r[i][2])==2(p[j][2]-r[i][2])==3(p[j][2]-r[i][2])==0)&&((p[j][3]-r[i][3])==2(p[j][3]-r[i][3])==0(p[j][3]-r[i][3])==3)&&((p[j][4]-r[i][4])==2(p[j][4]-r[i][4])==0(p[j][4]-r[i][4])==3))

c++;

}

if(c==0)

{

if(r[i][1]==0)

cout<<"A'";

if(r[i][1]==1)

cout<<"A";

if(r[i][2]==0)

cout<<"B'";

if(r[i][2]==1)

cout<<"B";

if(r[i][3]==0)

cout<<"C'";

if(r[i][3]==1)

cout<<"C";

if(r[i][4]==0)

cout<<"D'";

if(r[i][4]==1)

cout<<"D";

cout<<"+";

}

c=0;

}

cout<<endl;

for(i=1;i<c5;i++)

{

if(p[i][1]==0)

cout<<"A'";

if(p[i][1]==1)

cout<<"A";

if(p[i][2]==0)

cout<<"B'";

if(p[i][2]==1)

cout<<"B";

if(p[i][3]==0)

cout<<"C'";

if(p[i][3]==1)

cout<<"C";

if(p[i][4]==0)

cout<<"D'";

if(p[i][4]==1)

cout<<"D";

cout<<"+";

}

// getch ();

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Code of K'maps i n C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Find the sum of 1 plus 2 plus 3 plus . plus n nos using c program?

if (n%2==0) sum=n/2*(n+1); else sum=(n+1)/2*n;


What is the difference between n-- and --n in C plus plus statement?

If these expressions are stand-alone (not nested), then they do the same thing, ie increment 'n'.


C plus plus program for 1223334444..?

int n, i; for(n = 1; n &lt;= 5; ++n) { for(i = 1; i &lt;= n; ++i) { printf("%d", n); } }


Write c plus plus program to find all number from 112 to 212 with the cumulative total?

int total = 0; int n; for( n = 112; n &lt;= 212; ++n) { total += n; } printf("%d\n", total);


Program to sort numbers in c plus plus?

/* Bubble sort: code snippet only nos to be sorted are in the array named 'n' of size 'N' for(int i=0;i&lt;N-1;i++) for(int j=i+1;j&lt;N-1-i;j++) if(n[j]&gt;n[j+1]) swap(n[j],n[j+1]); */ /* insertion sort int v,j; for(int i=1;i&lt;N;i++) { v=n[j]; for(int j=i-1;j&gt;0&amp;&amp;n[j]&gt;v;j--) n[j+1]=n[j]; n[j+1]=v; } */

Related questions

What is the code of program in c plus plus that prints an hourglass of stars on screen?

#include&lt;iostream&gt; int main() { std::cout &lt;&lt; "*******\n" "*******\n" " *****\n" " ***\n" " *\n" " ***\n" " *****\n" "*******\n" "*******\n"; }


How do you construct the C plus plus program that will accept 10 integers number code?

#include&lt;iostream&gt; #include&lt;conio.h&gt; #include&lt;string&gt; int main() { std::cout &lt;&lt; "Enter your 10 digit code: "; size_t code=0; size_t len=0; while (len&lt;10) { char c = (char) _getch(); if (c=='0' &amp;&amp; !code) // leading zero not permitted! continue; if (c&gt;='0' &amp;&amp; c&lt;='9') { ++len; std::cout &lt;&lt; c; c -= '0'; code *= 10; code += c; } } std::cout &lt;&lt; "\n\nYou entered: " &lt;&lt; code &lt;&lt; '\n' &lt;&lt; std::endl; }


How do you write the subscript in c plus plus code using Balaguruswamy edition?

Subscripts have not changed since C++ evolved from C. Given an array x, the subscript x[n] returns a reference to the n-1th element of x. Note that Balaguruswamy is a book writer, he has not released any edition of C++.


What is a sample code for C plus plus?

Copy and paste this and it will say hello world! #include &lt;iostream&gt; int main() { std: :cout &lt; &lt; "Hello, world!\n ";


C program to convert gray code to binary code?

#include#includevoid main(){int a[10],i=0,c=0,n;printf("\n enter the gray code");scanf("%d",&n);while(n!=0){a[i]=n%10;n/=10;i++;c++;}for(i=c-1;i>=0;i--){if(a[i]==1){if(a[i-1]==1)a[i-1]=0;elsea[i-1]=1;}}printf("\n the binary code is");for(i=c-1;i>=0;i--)printf("%d",a[i]);getch();}


How do you make a diamond using for loop in C plus plus?

Here is the code to do it: #include&lt;stdio.h&gt; main() { int n, c, k, space = 1; //Here we ask for the number of rows would be : printf("Enter number of rows\n"); scanf("%d",&amp;n); space = n - 1; //This is the first half of the diamond for ( k = 1 ; k &lt;= n ; k++ ) { for ( c = 1 ; c &lt;= space ; c++ ) printf(" "); space--; for ( c = 1 ; c &lt;= 2*k-1 ; c++) printf("*"); printf("\n"); } space = 1; //Here is the second half of the diamond for ( k = 1 ; k &lt;= n - 1 ; k++ ) { for ( c = 1 ; c &lt;= space; c++) printf(" "); space++; for ( c = 1 ; c &lt;= 2*(n-k)-1 ; c++ ) printf("*"); printf("\n"); } return 0; } Hope that helped :)


How do you convert Binary code to BCD code?

#include#includevoid main(){int a[10],i=0,c=0,n;printf("\n enter the gray code");scanf("%d",&n);while(n!=0){a[i]=n%10;n/=10;i++;c++;}for(i=c-1;i>=0;i--){if(a[i]==1){if(a[i-1]==1)a[i-1]=0;elsea[i-1]=1;}}printf("\n the binary code is");for(i=c-1;i>=0;i--)printf("%d",a[i]);getch();}


What is code of 1-2 plus 3-4 plus 5-6 plus ...n in c plus plus?

Did you mean 1-2+3-4+5-6....till n ?? If yes, then here it is: #include&lt;iostream.h&gt; void main() { int n,sum=0,check=1; cout&lt;&lt;"Enter n "; cin&gt;&gt;n; for(int i=1;i&lt;=n;i++) { sum+=(check*i); check*=-1; } cout&lt;&lt;"The result of series is: "&lt;&lt;sum; }


Find the sum of 1 plus 2 plus 3 plus . plus n nos using c program?

if (n%2==0) sum=n/2*(n+1); else sum=(n+1)/2*n;


What is the difference between n-- and --n in C plus plus statement?

If these expressions are stand-alone (not nested), then they do the same thing, ie increment 'n'.


How do you write a program if a person has to travel n cities using n-1 paths in c plus plus code?

Depending on the setup, this problem can be unsolvable. It belongs to a class of problems known as NP complete, meaning that no easily solvable solution can be provided.


How do you find the C programming of the sum of the series 5 plus 55 plus 555 plus . plus n terms?

Find the Sum to n terms of the series 5 5+55+555+ +n Terms