测试用例全通过,提交代码15分
查看原帖
测试用例全通过,提交代码15分
1336398
xprintiny楼主2024/5/1 13:49
#include<bits/stdc++.h>
using namespace std;
void over(char s[]){
	char temp;
	for(int i=0,j=strlen(s)-1;i<j;i++,j--){
		temp=s[i];
		s[i]=s[j];
		s[j]=temp;
	}
}
void oprint(char s[],bool f=0){
	int i=0,j=strlen(s)-1;
	while(s[i]=='0') i++;
	if(f){
		while(s[j]=='0') j--;
	}
	while(i<=j){
		cout<<s[i];
		i++;
	}
}
int main(){
	char s[30],a[30],b[30];
	char *p=a;
	char sign;
	gets(s);
	for(int i=0;s[i]!='\0';i++){
		if(s[i]=='\b') continue;
		if(s[i]=='.' || s[i]=='/' || s[i]=='%'){
			p=b;
			sign=s[i];
		}
		else{
			*p = s[i];
			p++;
		}
	}
	*(++p)='\0';
	over(a);
	oprint(a,0);
	cout<<sign;
	if(b[0]!='\0'){
		over(b);
		oprint(b,(sign=='.'));
	}
	return 0;
}
2024/5/1 13:49
加载中...