青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 7,comments - 3,trackbacks - 0

Professor Maple teaches mathematics in a university. He have invented a function for the purpose of obtaining the operands from an expression. The function named op(i,e) can be described as follows: The expression e may be divided into sub-expression(s) by the operator, which has the lowest priority in the expression. For example, the expression “a*b+b*c+c*d” should be divided into three sub-expressions “a*b”, “b*c” and “c*d”, because the operator “+” has the lowest priority. The purpose of this function is to extract the ith sub-expression as the result. So, in the example above, op(2,e)=b*c.

If we regard the sub-expression as the main expression, it might be divided again and again. Obviously, the dividing process is recursive. As you see, the following example is much more complex:

Let p:=a^b*c+(d*c)^f*z+b
op(1,op(1,op(2,p)))=(d*c)
op(1,op(1,op(1,op(2,p))))=d*c
op(2,op(2,p))=z
op(3,p)=b
op(1,op(3,p))=b

Professor Maple is so lazy that he would leave the work to computer rather than do it himself, when the expression is long and complicated. Of course, without your program, the computer won’t work out the result automatically.

Input

The input file contains several test cases. The last test case in the input file is followed by a line containing a symbol “*”, indicating the end of the input data. Each test case consists of two parts. The first part describes the expression, while the second part contains several questions, which should be calculated according to the expression.

The first line of each test case contains an expression consists of the expression name, “:=” and the content of the expression. The expression name is a lowercase. And the content is composed by lowercases and operators “+”, “(”, “)”, “*” and “^”. For example, here is a valid expression, p:=a^b*c+(d*c)^f*z+b. Among those operators, “(” and “)” have the highest priority. The operator “^” has a lower priority, and then “*”. The priority of the operator “+” is the lowest.

The second line of each test case contains an integer n indicating n questions based on the above expression. This is followed by n lines. Each of them contains the description of one question, which consists of integers. For example, the question with three integers “2 1 1” describes the function op(1,op(1,op(2,e))). To compute this function, we have to keep to the following sequence: First, according to the first integer 2, divide the expression and extract the 2nd sub-expression. Then, according to the second integer 1, divide the sub-expression and extract the 1st one. Finally, according to the third integer 1, divide the outcome again, and extract the result.

Output

For each test case, display the expression name and a colon on the first line. Then display the result of each question on a line. The layout of the output is shown in the sample output.

You may assume that all expressions and functions are always valid.

Display a blank line between test cases.

Sample Input

p:=a^b*c+(d*c)^f*z+b 
4
2 1 1
2 2
3
3 1
a:=(x+y)
3
1
1 2
1 2 1
*

Sample Output

Expression p: 
op(1,op(1,op(2,p)))=(d*c)
op(2,op(2,p))=z
op(3,p)=b
op(1,op(3,p))=b

Expression a:
op(1,a)=x+y
op(2,op(1,a))=y
op(1,op(2,op(1,a)))=y


模擬題,處理好原字符串的優先級就行了。
代碼:
#include <iostream>
#include 
<cstring>
#include 
<cstdio>
using namespace std;

int find(char c)
{
    
if (c == '(' || c == ')'return 4;
    
if (c == '^'return 3;
    
if (c == '*'return 2;
    
if (c == '+'return 1;
    
return 1000;
}

char s[101];
string e;
int n, i, j, k, p[101], r[101], v[101], head, tail, x, ri, d = 0;

int main()
{
    
while (scanf("%s", s), s[0!= '*')
    {
        
if (d++) puts("");
        head 
= 0;
        e 
= "";
        
while (s[head] != ':')
          e 
+= s[head++];
        head 
+= 2;
        printf(
"Expression %s:\n", e.c_str());
        tail 
= strlen(s) - 1;
        x 
= 0;
        
for (i = head; i <= tail; ++i)
        {
            
if (s[i] == ')') x -= 4;
            v[i] 
= find(s[i]) + x;
            
if (s[i] == '(') x += 4;
        }
        scanf(
"%d\n"&k);
        
for (i = 0; i < k; ++i)
        {
            ri 
= 0;
            
int head1 = 3, min1, t;
            tail 
= strlen(s);
            
char c;
            
while ((c = getchar()) != '\n')
            {
                cin.putback(c);
                scanf(
"%d"&n);
                r[ri
++= n;
                min1 
= 1000;
                
for (j = head1; j < tail; ++j)
                  
if (v[j] < min1) min1 = v[j];
                
if (s[head1] == '(' && s[tail - 1== ')' && min1 == v[head1])
                {
                    head1
++;
                    tail
--;
                }
                
else
                  
if (head1 + 1 == tail){}
                
else
                {
                    p[
0= head1 - 1;
                    
for (j = head1, t = 1; j < tail; ++j)
                      
if (v[j] == min1)
                      {
                          p[t
++= j;
                      }
                    p[t] 
= tail;
                    head1 
= p[n - 1+ 1;
                    tail 
= p[n];
                }
            }
            
for (j = ri - 1; j >= 0--j)
              printf(
"op(%d,", r[j]);
            printf(
"%s", e.c_str());
            
for (j = 0; j < ri; ++j)
              printf(
")");
            printf(
"=");
            
for (j = head1; j < tail; ++j)
                printf(
"%c", s[j]);
            puts(
"");
        }
    }
    
return 0;
}
posted on 2011-10-25 19:53 LLawliet 閱讀(261) 評論(0)  編輯 收藏 引用 所屬分類: 模擬

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美日韩国产综合久久| 亚洲欧美一区二区激情| 亚洲国产高潮在线观看| 99精品久久| 欧美在线视频免费观看| 亚洲精美视频| 久久精品理论片| 国产精品v欧美精品v日韩精品| 国产亚洲一区二区精品| 一区二区三区日韩精品视频| 久久亚洲私人国产精品va媚药| av成人福利| 久久中文字幕导航| 国产欧美一区二区白浆黑人| 中文在线不卡| 亚洲激情一区二区| 欧美午夜一区二区三区免费大片| 性久久久久久久久久久久| 亚洲日本中文字幕免费在线不卡| 久久精品伊人| 亚洲免费福利视频| 亚洲国产日韩一区| 免费成人在线观看视频| 国色天香一区二区| 久久精品视频播放| 欧美一区二区三区成人| 国产九色精品成人porny| 亚洲综合电影| 亚洲最黄网站| 在线观看成人av| 麻豆国产精品va在线观看不卡| 亚洲欧美日韩在线一区| 亚洲第一毛片| 亚洲第一搞黄网站| 国产欧美日韩精品专区| 亚洲国产一区二区精品专区| 国产啪精品视频| 亚洲国语精品自产拍在线观看| 国产精品丝袜白浆摸在线| 亚洲欧美成aⅴ人在线观看| 夜夜嗨av色综合久久久综合网| 国产一区二区三区在线观看免费视频 | 亚洲国产日韩美| 蜜桃久久av| 免播放器亚洲一区| 欧美中文字幕久久| 欧美日韩美女| 欧美一区二区三区四区在线| 欧美在线二区| 亚洲黑丝一区二区| 欧美在线|欧美| 亚洲午夜电影在线观看| 先锋影音国产精品| 在线精品观看| 欧美一级播放| 翔田千里一区二区| 欧美日韩天堂| 欧美激情久久久久久| 欧美肉体xxxx裸体137大胆| 久久av一区| 国产精品久久久久久久久免费樱桃 | 久久伊人精品天天| 国产精品丝袜白浆摸在线| 日韩视频免费| 国产一区二区你懂的| 亚洲一级二级| 亚洲高清电影| 一区二区毛片| 亚洲成人中文| 久久久久久久999| 亚洲婷婷综合久久一本伊一区| 欧美激情欧美激情在线五月| 久久精品国产免费观看| 国产麻豆午夜三级精品| 亚洲免费一级电影| 一本大道久久精品懂色aⅴ| 欧美在线视频全部完| 久久日韩粉嫩一区二区三区| 欧美日本韩国| 欧美wwwwww| 国产一区二区三区久久精品| 欧美在线看片a免费观看| 免费人成网站在线观看欧美高清| 1000部国产精品成人观看| 欧美成人dvd在线视频| 久久精品最新地址| 国产精品扒开腿爽爽爽视频 | 免费日韩精品中文字幕视频在线| 在线看国产一区| 欧美激情一区二区三区在线| 一区二区三区视频在线| 久久精品视频免费观看| 亚洲第一毛片| 欧美午夜一区二区| 久久狠狠婷婷| 久久精品免费播放| 亚洲国产欧美日韩精品| 欧美三级韩国三级日本三斤| 亚洲欧洲99久久| 欧美激情久久久久| 亚洲欧美日韩在线播放| 1000部国产精品成人观看| 欧美日韩精品免费观看| 欧美一区二区三区视频在线观看| 欧美成人视屏| 亚洲国产精品一区制服丝袜| 欧美日韩www| 午夜精品一区二区三区电影天堂| 欧美黄色精品| 午夜欧美精品| 国产日韩在线一区| 欧美一区二区高清在线观看| 亚洲国产精品一区| 久久国产精品99久久久久久老狼| 亚洲欧洲在线免费| 欧美日韩国产小视频| 欧美制服丝袜第一页| 日韩视频永久免费观看| 老司机午夜精品视频在线观看| 亚洲无线一线二线三线区别av| 伊人狠狠色j香婷婷综合| 国产精品视频久久| 欧美另类亚洲| 欧美a一区二区| 亚洲毛片一区| 久久国产精品第一页| 亚洲午夜在线视频| 亚洲精品久久久久久下一站| 欧美日韩国产一级| 能在线观看的日韩av| 久久aⅴ国产欧美74aaa| 亚洲欧美一区二区三区在线| 一区电影在线观看| 亚洲欧洲精品一区二区三区波多野1战4| 欧美自拍偷拍| 欧美一级片在线播放| 亚洲欧美变态国产另类| 国产精品99久久久久久久女警| 亚洲精品视频在线| 亚洲人线精品午夜| 亚洲人成毛片在线播放| 亚洲精品123区| 亚洲国产经典视频| 亚洲电影在线看| 在线观看亚洲一区| 亚洲高清二区| 亚洲二区在线观看| 91久久久国产精品| 亚洲啪啪91| 一本大道久久a久久精品综合 | 国产欧美精品一区二区色综合| 欧美午夜免费| 国产精品成人一区| 久久久久久久999| 久久久久免费视频| 男人插女人欧美| 欧美精品999| 欧美亚洲不卡| 国产欧美日本| 曰本成人黄色| 亚洲精品一二三| 在线视频中文亚洲| 亚洲女人天堂av| 久久精品水蜜桃av综合天堂| 另类尿喷潮videofree| 欧美刺激性大交免费视频| 亚洲人成在线影院| 一区二区激情| 欧美在线视频免费观看| 欧美不卡视频| 国产精品扒开腿做爽爽爽视频 | 国产精品综合| 精品电影一区| 国产精品系列在线播放| 黄色成人免费观看| 一本色道久久综合狠狠躁篇的优点 | 欧美成人精品在线观看| 欧美日韩免费高清| 国产日韩精品在线播放| 亚洲日本激情| 欧美在线视频不卡| 亚洲国产清纯| 午夜欧美精品久久久久久久| 欧美a级一区| 国产欧美日韩一区二区三区在线观看 | 亚洲激情另类| 午夜电影亚洲| 欧美成人激情视频免费观看| 99精品视频免费观看视频| 欧美一区三区二区在线观看| 欧美精品午夜视频| 国内精品视频一区| 国产综合色精品一区二区三区| 亚洲人成绝费网站色www| 久久国产精品一区二区| 亚洲狼人综合| 久久婷婷国产综合国色天香| 麻豆av福利av久久av| 国产精品乱码久久久久久| 亚洲精品久久久久久久久久久久久|