sahar_2010
یک شنبه 15 مرداد 1391, 23:42 عصر
خواهش میکنم بگید مشکل این کد چیه؟
#include <conio.h>
#include <iostream>
#include <string.h>
using std::cout;
using std::cin;
using std::endl;
void twovariables();
int code();
char c1=0;
int main(){
int num; // stores the number of variables entered by user
cout<<"Enter number of Karnaugh map variables (2,3 or 4)";
cin>>num;
if(num==2) twovariables();
while (num>4 || num <2 ){
cout<<"wrong number!\n";
cout<<"Enter number of Karnaugh map variables (2,3 or 4)";
cin>>num;
}
getch();
}
/*******************************/
/*
/* 2 variable karnaugh map
/*
/*******************************/
void twovariables()
{
char o[100];for(int i=0;i<100;i++)o[i]=0;
char var[100];for(int i=0;i<100;i++)var[i]=0;
int a[100];for(int i=0;i<100;i++)a[i]=0;
int i=0;
cout<<"the expression is: ";
cin>>var;
sa:
if(var[i]=='+'){
a[i]=code();
i++;
goto sa;
c1=0;
}
else{
o[i]=var[i];
c1=o[i];
i++;
goto sa;
}
cout<<"\n "<<a[0]<<"\n "<<a[1]<<"\n "<<a[2]<<"\n "<<a[3];
}
int code(){
int a[100];for(int i=0;i<100;i++)a[i]=0;
switch(c1){
case 'x`y`': a[0]=1;
case 'x`y' : a[1]=1;
case 'xy`' : a[2]=1;
case 'xy' : a[3]=1;
}
return 0;
}
#include <conio.h>
#include <iostream>
#include <string.h>
using std::cout;
using std::cin;
using std::endl;
void twovariables();
int code();
char c1=0;
int main(){
int num; // stores the number of variables entered by user
cout<<"Enter number of Karnaugh map variables (2,3 or 4)";
cin>>num;
if(num==2) twovariables();
while (num>4 || num <2 ){
cout<<"wrong number!\n";
cout<<"Enter number of Karnaugh map variables (2,3 or 4)";
cin>>num;
}
getch();
}
/*******************************/
/*
/* 2 variable karnaugh map
/*
/*******************************/
void twovariables()
{
char o[100];for(int i=0;i<100;i++)o[i]=0;
char var[100];for(int i=0;i<100;i++)var[i]=0;
int a[100];for(int i=0;i<100;i++)a[i]=0;
int i=0;
cout<<"the expression is: ";
cin>>var;
sa:
if(var[i]=='+'){
a[i]=code();
i++;
goto sa;
c1=0;
}
else{
o[i]=var[i];
c1=o[i];
i++;
goto sa;
}
cout<<"\n "<<a[0]<<"\n "<<a[1]<<"\n "<<a[2]<<"\n "<<a[3];
}
int code(){
int a[100];for(int i=0;i<100;i++)a[i]=0;
switch(c1){
case 'x`y`': a[0]=1;
case 'x`y' : a[1]=1;
case 'xy`' : a[2]=1;
case 'xy' : a[3]=1;
}
return 0;
}