思想
这道题我就用一个指针从头走到尾做的:
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
cin.tie(nullptr)->sync_with_stdio(0);
string s;cin>>s;
string s1,s2;
int i=0;
while(s[i]!='*')
{
s1+=s[i];
i++;
}
char op=s[i];
i++;
while(i<s.size())
{
s2+=s[i];
i++;
}
int t1=stoi(s1);
int t2=stoi(s2);
cout<<t1*t2;
return 0;
}
评论区更简单的做法: