#include <bits/stdc++.h> using namespace std; int index=0; int sum[1000]; int jia(string a,int i){ if(a.find("+")<0 || a.length<a.find("+")){ return stoi(a); } index=i+1; int a1=stoi(a.substr(0,a.find("+"))); string b1=a.substr(a.find("+")+1); sum[index]=jia(b1,index); } int main(){ string a; getline(cin,a); sum[0]=jia(b1,index); for(int i=0;i<index;i++){ int x=sum[0]; int y=sum[1]; } cout<<x+y; return 0; }
标签:std,index,string,jia,int,加法 From: https://www.cnblogs.com/fushuxuan/p/17839574.html