الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[مخالف - طلب حل : ]يا أخوان محتاج مساعدة في لغة الس Convert Fully Parenthesized

مغلق
بدأه myname611 في 21 أكتوبر 2008 · 1 رد · 276 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

هدا هو الواجب

Write a program to convert fully parenthesized

infix notation to suffix notation.

Fully parenthesized infix example:

((a+B)*(c/d))$

(the $ is an end marker)

The suffix for the above:

ab+cd/*

In suffix notation, the operator follows

the operands.

Your program:

- all operands will be single letters.

- a $ will indicate the end of the string.

- no embedded blanks.

Algorithm:

read a character from the input.

- if it is a $ you are done - see below.

- if it is a open paren, ignore it.

- if it is an operand, write it to the output.

- if it is an operator (+-*/), push it on a stack.

- if it is a close paren, pop the top of stack to output

use getchar() for input and putchar(int) for output.

the stack: an array with a corresponding index like:

char stack[20];

int stx = 0;

to push: put the character into stack[stx] then increment

stx.

to pop to output: decrement stx and putchar(stack[stx]);

when done, check to see that the stack is empty (stx==0).

if not, this is an error situation.

what does all this mean? suffix notation can be directly

executed by a computer whereas infix cannot. converting

input to suffix can be the first step to executing an

expression. some advanced calculators require you to

enter your expressions in suffix notation.

#2

الأخ الكريم/الأخت الكريمة

السلام عليكم ورحمة الله وبركاته.

مرحباً بكم في منتدى الفريق العربي للبرمجة

تأسف إدارة المنتدى لغلق الموضوع وذلك لمخالفته قوانين المشاركات، فقرة طلب حل الواجبات والتمارين وأعمال السنة.

قواعد طرح المشاركات

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

tvquran_6.gif

هذا الموضوع مغلق.

مواضيع مشابهة