#5#19WA,已开unsigned
查看原帖
#5#19WA,已开unsigned
1351192
Yancy0423楼主2024/7/25 20:15
#include<bits/stdc++.h>
using namespace std;
string input;
long long front=0,back=0;
char type;
int cnt;
bool b=0;
void cut(){
	int time=0;
	for(int i=0;i<input.length();i++){	
		if(input[i]<'0'||input[i]>'9') {
			type=input[i];
			cnt=i;
			break;
		}
		front+=(input[i]-'0')*pow(10,time);
		time++;
	}
	time=0;
	for(int j=cnt+1;j<input.length();j++){
		back+=(input[j]-'0')*pow(10,time);
		time++;
	} 
}
void sub0(){
	while(back%10==0)
		back/=10;
}
int main(){
	cin>>input;
	cut();
	if(type=='\0') {
		for(int i=input.length()-1;i>=0;i--){
			if(input[i]!='0') b=1;
			if(b) cout<<input[i];
			}
	}
	else if(type=='%') cout<<front<<"%";
	else if(type=='.'){
		if(back!=0) sub0();
		cout<<front<<type<<back;
	}
	else cout<<front<<type<<back;
	return 0;
}
2024/7/25 20:15
加载中...