1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
The following is my code so far:
#include <iostream>
#include <string>
using namespace std;
enum Type {VAR,BIN,UNI};
void printExpression ( Type a[], string b[],int c[],int d[]){
for (int i=0; i<12; i++){
if (c[i] && d[i]==-1){
c[i]=NULL;
d[i]=NULL;
}
cout<<a[i]<<" "<<b[i]<<""<<c[i]<<""<<d[i]<<endl;
}
}
int main(){
string names[12]={"x","y","z","-","*","+","/",">","!"};
Type type[12]={VAR,VAR,VAR,UNI,BIN,BIN,BIN,UNI,BIN,BIN,UNI};
int oper1[12]={-1,-1,-1,0,1,1,5,6,1,7,9};// index incase entry was operation
int oper2[12]={-1,-1,-1,-1,3,2,4,-1,2,8,-1};//index of the second operand if binary
string values[12];
printExpression(type, names, oper1,oper2);
system ("pause");
return 0;
}
|