样例过了0分求调
查看原帖
样例过了0分求调
910982
Lhy153楼主2024/1/23 09:10
#include<bits/stdc++.h> 
using namespace std;
int n;
char r[55];
int hhh(int x,int y,int z){
	int n;
	if(z<0) n++,z=-z; 
	while(x>0) x=x/10,n++;
	while(y>0) y=y/10,n++;
	while(z>0) z=z/10,n++;
	return n+2;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		char a[10086];
		int b,c;
		cin>>a>>b;
		if(a[0]!='a'&&a[0]!='b'&&a[0]!='c'){
			int e=atoi(a);
			for(int j=i;j>=1;j--){
				if(r[j]!='a'&&r[j]!='b'&&r[j]!='c') continue;
				else{
					if(r[j]=='b'){
						cout<<e<<"-"<<b<<"="<<e-b<<endl;
						cout<<hhh(e,b,e-b)<<endl;
					}
					else if(r[j]=='c'){
						cout<<e<<"*"<<b<<"="<<e*b<<endl;
						cout<<hhh(e,b,e*b)<<endl;
					}
					else if(r[j]=='a'){
						cout<<e<<"+"<<b<<"="<<e+b<<endl;
						cout<<hhh(e,b,e+b)<<endl;
					}
				}
			}
		}
		else if(a[0]=='b'){
			cin>>c;
			r[i]=a[0];
			cout<<b<<"-"<<c<<"="<<b-c<<endl;
			cout<<hhh(b,c,b-c)<<endl;
		}
		else if(a[0]=='c'){
			cin>>c;
			r[i]=a[0];
			cout<<b<<"*"<<c<<"="<<b*c<<endl;
			cout<<hhh(b,c,b*c)<<endl;
		}
		else if(a[0]=='a'){
			cin>>c;
			r[i]=a[0];
			cout<<b<<"+"<<c<<"="<<b+c<<endl;
			cout<<hhh(b,c,b+c)<<endl;
		}
	}
    return 0;
}
2024/1/23 09:10
加载中...