題目1101 計算表示式 RE

2021-06-17 14:46:14 字數 868 閱讀 4934

題目描述:對於乙個不存在括號的表示式進行計算

輸入:存在多種資料,每組資料一行,表示式不存在空格

輸出:輸出結果

樣例輸入:

6/2+3+3*4

樣例輸出:

18

**:

#include #include using namespace std;

stackin;

stackop;

char str[100];

int p[5] = ;

void getop(bool &retop, int &retnum, int &i)

if(str[i]==0)

if(str[i]>='0' && str[i]<='9')

retop = false;

else

retnum = 0;

while(str[i]>='0'&&str[i]<='9')

return;

}int main()

op.push(retnum);}}

if(op.size()==2 && op.top()==0)

break;

}int ans = (int) in.top();

printf("%d\n",ans);

}return 0;

}

在自己機器上測試結果正確。但是提交時:runtime error.

九度1101 計算表示式

題目描述 對於乙個不存在括號的表示式進行計算 輸入 存在多種資料,每組資料一行,表示式不存在空格 輸出 輸出結果 樣例輸入 6 2 3 3 4 樣例輸出 18 過不去。一直wawawawawawawa include include include include include include i...

題目29 計算表示式

題目描述 對於乙個不存在括號的表示式進行計算 輸入 存在多種資料,每組資料一行,表示式不存在空格 輸出 輸出結果 樣例輸入 6 2 3 3 4 樣例輸出 18 1 include 2 include 3 include 4 include 5 using namespace std 67 int p...

九度OJ 1101 計算表示式

題目描述 對於乙個不存在括號的表示式進行計算 輸入 存在多種資料,每組資料一行,表示式不存在空格 輸出 輸出結果 樣例輸入 6 2 3 3 4 樣例輸出 18這個題目一行輸入可能有多個表示式 方法1 include include using namespace std char str 220 儲...