anagram
Chat with our AI personalities
Conversion of a Regular Expression to NFA Algorithm Source code C programmingCS342 Compiler Lab Source code Algorithm C Programming #include#includevoid main(){char reg[20];int q[20][3],i,j,len,a,b;clrscr();for(a=0;a
#include #include int main() { int i,j,k,l,m,n,p,q,temp,fno,secno,thirdno; int arr[1][9]; cout<<"---------------------------------------ABRAR TARIQ-------------------------------"< cout<<"Here are the all possible combinations of the triad numbers between 1 to 1000 ! cheers !"< int a=0; for(i=100;i<=1000;i++) { for(j=i+1;j<=1000;j++) { if(j==2*i) { fno=i; secno=j; } if(j==3*i) { thirdno=3*i; } } k=fno/100; temp=fno%100; l=temp/10; m=temp%10; arr[0][0]=k; arr[0][1]=l; arr[0][2]=m; k=secno/100; temp=secno%100; l=temp/10; m=temp%10; arr[0][3]=k; arr[0][4]=l; arr[0][5]=m; k=thirdno/100; temp=thirdno%100; l=temp/10; m=temp%10; arr[0][6]=k; arr[0][7]=l; arr[0][8]=m; for(n=0;n<1;n++) { for(p=0;p<9;p++) { for(q=p+1;q<9;q++) { if(arr[n][p]==arr[n][q]arr[n][p]==0arr[n][q]==0) { a=1; } if(a==1) break; } if(a==1) { a=0; break; } } if(p==9&&q==9&&a==0) { cout<<<","<<<","<<< cout<<"---And---"< } } return 0; }
#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 (); }
K j equals j when K is 1 or j is 0.
#include<stdio.h> void main() { int a[5],b[5]; int c[10]; int i,j,temp,k; printf("\n enter the elements of array A:=\n"); for(i=0;i<5;i++) scanf("%d",&a[i]); printf("\n enter the elements of array B:=\n"); for(i=0;i<5;i++) scanf("%d",&b[i]); for(i=1;i<5;i++) { for(j=0;j<5-i;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } for(j=0;j<5-i;j++) { if(b[j]>b[j+1]) { temp=b[j]; b[j]=b[j+1]; b[j+1]=temp; } } } printf("\n the elements of the array A:=\n"); for(i=0;i<5;i++) printf("%d\t",a[i]); printf("\n the elements of the array B:=\n"); for(i=0;i<5;i++) printf("%d\t",b[i]); i=0,j=0,k=0; while(i<5&&j<5) { if(a[i]>b[j]) c[k++]=b[j++]; if(a[i]<b[j]) c[k++]=a[i++]; } if(i<5&&j==5) while(i<5) c[k++]=a[i++]; if(i==5&&j<5) while(j<5) c[k++]=b[j++]; printf("\n the elements of the sorted merged array C:=\n"); for(i=0;i<10;i++) printf("%d\t",c[i]); }