求大佬看一下,55分
查看原帖
求大佬看一下,55分
481851
Withers楼主2022/1/3 22:14

RT,本地似乎没问题

#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[100];
	int now=0;
	char p;
	while(1)
	{
		char ch=getchar();
		if(!(ch>='0'&&ch<='9'))
		{
			p=ch;
			break;
		}
		s[++now]=ch;
	}
	bool y=0;
	for(int i=now;i>=1;i--)
	{
		if(y==1) cout<<s[i];
		if(y==0&&s[i]!='0') 
		{
			y=1;
			cout<<s[i];
		}
	}
	y=0;
	if(p=='\n'||p=='\r') return 0;
	if(p=='%')
	{
		cout<<"%";
		return 0;
	}
	cout<<p;
	now=0;
	while(1)
	{
		char ch=getchar();
		if(!(ch>='0'&&ch<='9'))
		{
			p=ch;
			break;
		}
		s[++now]=ch;
	}
	int l=0,r=now;
	while(s[l+1]=='0'&&l<now-1) l++;
	while(s[r]=='0'&&r>l+1) r--; 
	for(int i=r;i>l;i--)
        cout<<s[i];
}
2022/1/3 22:14
加载中...