دو چند جمله ای را از ورودی دریافت و آن دو را با هم جمع و تفریق و ضرب نماید.من این برنامه رو به صورت پایین نوشتم
#include<stdio.h> struct stack { int top; char item[10]; }; int isfull(struct stack *ps) { if(ps->top==9) { return(1); } else { return(0); } } int isempty(struct stack *ps) { if(ps->top==-1) { return(1); } else { return(0); } } void push(struct stack *ps,char a) { ps->top++; ps->item[ps->top]=a; } void pop(struct stack *ps) { ps->top--; } void display(struct stack *ps) { int i=ps->top; printf("\nthe stack contains:\n"); for(i=ps->top;i!=-1;--i) { printf("%c",ps->item[i]); } } void main() { struct stack s; int ch,n; char a,b; s.top=-1; do { printf("\nenter your choice:\n1.push\n2.pop\n3.display\n4.exit"); scanf("%d",&ch); switch(ch) { case 1: if(isfull(&s)) { printf("\nstack is full"); } else { printf("\nenter character to be pushed:"); scanf("%s",&a); push(&s,a); } break; case 2: if(isempty(&s)) { printf("\nstack is empty"); } else { pop(&s); } break; case 3: if(isempty(&s)) { printf("\nstack is empty"); } else { display(&s); } break; } } while(ch!=4); }
ولی استادمون گفت توان و ضریب را جدا جدا نباید حساب کرد باید توان و ضریب با هم حساب شوند اگه میشه تو این مسئله خط به خط راهنمایم کنسد یه دنیا ممنون میشم![]()