数据过了但就是0分,求助大佬!
查看原帖
数据过了但就是0分,求助大佬!
358875
おはよう楼主2021/5/19 18:53
#include <cstring>
#include <cstdio>
#include <iostream>

using namespace std;

int a[1001];

int judge(string s){
	
	int tot = 0,i = 0,x;
	
	while(s[i] != '@'){
		
		switch (s[i]){
			
			case '+':
				a[--tot] = a[tot] + a[tot+1];
				break;
			case '-':
				a[--tot] = a[tot] - a[tot+1];
				break;
			case '*':
				a[--tot] = a[tot] * a[tot+1];
				break;
			case '/':
				a[--tot] = a[tot] / a[tot+1];
				break;
			
			default :
				
				x = 0;
				tot++;
				while (s[i] != '.'){
					
					x = x*10 + (s[i] - '0');
					i++;
					
				}
				a[tot] = x;
				break;
		}
		
		i++;
		
	}
	
	return a[tot];
}

int main (){
	
	string s;
	cin >> s;
	cout << judge(s);
	
	return 0;
}
2021/5/19 18:53
加载中...