____蒟蒻____ @ 2018-12-02 17:45:17
第二组数据是这样的 10.28.30./*7.-@ 那么28/30得出来的应该是0呢还是个小数呢 代码:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
struct stack {
double s[100005];
int _top;
stack(double _top=0) {
this->_top=_top;
}
void push(double x) {
s[_top]=x;
_top++;
}
void pop() {
_top--;
}
double top() {
return s[--_top];
}
bool empty() {
return _top==0;
}
double size() {
return _top;
}
};//~~愉快的手写栈~~
string read() {
string tmp;
cin>>tmp;
return tmp;
}
int main () {
string n=read();
double now=0;
stack num;
for (double i=0; n[i]!='@'; i++) {
if (isdigit(n[i])) {
now=now*10+(n[i]^48);
continue;
}
if (n[i]=='.') {
num.push(now);
now=0;
continue;
}
double ai=num.top(), bi=num.top(), ans;
switch(n[i]) {
case '+': {
ans=ai+bi;
num.push(ans);
break;
}
case '-': {
ans=bi-ai;
num.push(ans);
break;
}
case '*': {
ans=bi*ai;
num.push(ans);
break;
}
case '/': {
ans=bi/ai;
num.push(ans);
break;
}
}
}
printf("%.0lf", num.top());
return 0;
}
by Jameswood @ 2018-12-02 17:50:34
忘了.jpg
by loi_hjh @ 2018-12-02 18:24:11
80分
by rong_nian @ 2018-12-02 18:27:28
得出的应该是0