Lisans’da 2. sınıftayken geliştirdiğimiz ve benim C++’ı anlamamda çok fazla yardımı olan bir ödevi paylaşıyor olacağım bu yazımda. Bir input dosyasından aldığı eşitliği operatorlerin önceliği ve parantezleri de göz önüne alarak stack ve queue yapılarını kullanarak sonucu başka bir dosyaya yazıyor. Aşağıdaki ekte raporumu da paylaşıyorum ancak en önemli kısma gelirsek o da aşağıda yer almakta. 😉
// At this class, the line which includes the equation is broken into peaces like number, operator parameter* stack_operations::stack_operations_(string line){
cout << line; // write the command line to screen cout << "\n"; parameter *ptr; queue <parameter *> stack_k; // queue to take the peaces of command line
for(int i=0;i<line.length();i++){
if(!isdigit(line[i]) && i>=4){ // if the character is not isdigit String *s = new String(); // create a new pointer from String class s->set_value(line[i]); // set down the value
if(line[i]=='(' || line[i]==')') // if character is parantecis, assign -1 as precedence to control s->set_precedence(-1); Continue reading