只过一个点,求助!!!
查看原帖
只过一个点,求助!!!
462258
JuliusCaesar楼主2021/10/3 16:16
#include <bits/stdc++.h>
using namespace std;
int Num(int n){
	if(n>=0 && n<10) return 1;
	else if(n>=10 && n<100) return 2;
	else if(n>=100 && n<1000) return 3;
	else if(n>=1000 && n<10000) return 4;
	else if(n<0 && n>-10) return 2;
	else if(n<=-10 && n>-100) return 3;
	else if(n<=-100 && n>-1000) return 4;
	else if(n<=-1000 && n>-10000) return 5;
}
char Change(char a){
	if(a=='a') return '+';
	else if(a=='b') return '-';
	else if(a=='c') return '*';
}
int Com(int a,int b,char x){
	if(x=='+') return a+b;
	else if(x=='-') return a-b;
	else if(x=='*') return a*b;
}
int n,a,b;
char type,ty;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		if(cin>>type>>a>>b){
			ty=type;
			cout<<a<<Change(type)<<b<<'='<<Com(a,b,Change(type))<<endl;
			int c=Com(a,b,Change(type));
			cout<<Num(a)+Num(b)+Num(c)+2<<endl;
		}
		if(cin>>a>>b){
			cout<<a<<Change(ty)<<b<<'='<<Com(a,b,Change(ty))<<endl;
			int c=Com(a,b,Change(ty));
			cout<<Num(a)+Num(b)+Num(c)+2<<endl;
		}
	}

	return 0;
}

除了第一个点其它全WA

2021/10/3 16:16
加载中...