其他分享
首页 > 其他分享> > 测试

测试

作者:互联网

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
const ll mod = 1e5 + 3;
const ll N = 2e5 + 9;
using namespace std;
char c,a;
ll f=1,now=1,k,b,x;
bool r;
void f0()
{
    while(cin>>c)
    {
        if(c=='-')
        {
            b+=now*f*x;
            x=0;
            f=-1;
            r=0;
        }
        else if(c=='+')
        {
            b+=now*f*x;
            x=0;
            f=1;
            r=0;
        }
        else if(c=='=')
        {
            b+=now*f*x;
            x=0;
            f=1;
            now=-1;
            r=0;
        }
        else if(c>='a'&&c<= 'z')
        {
            if(r)
            {
                k+=now*f*x;
                x=0;
            }
            else
				k+=now*f;
            a=c;
            r=0;
        }
        else if(c>='0'&&c<='9')
        {
            x=x*10+c-'0';
            r=1;
        }
    }
    b+=now*f*x;
    double ans=double(-b*1.0/k);
    if(ans==-0.0)
		ans=0;
    printf("%c=%.3lf",a,ans);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll T = 1;
//	cin>>T;
    while (T--)
        f0();
    return 0;
}

 

标签:f0,ll,else,测试,using,now,define
来源: https://www.cnblogs.com/2021sgy/p/16561229.html