70分求助!
查看原帖
70分求助!
975726
C202301楼主2023/7/28 19:27
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;
int main()
{
	string s,st,str,stri,strin,_strin,_s;
	bool can=0;
	short b=0,a,e=0,f=0,g=0,h=0;
	unsigned long long c,d,i,j,k,l;
	cin>>s;
	for(a=0;a<s.size();a++)
	{
		if(s[a]=='.') 
		{
			b=1;
			e=a-1;
			g=a+1;
			f=s.size()-1-e;
			break;
		}
		if(s[a]=='/')
		{
			b=2;
			e=a-1;
			g=a+1;
			f=s.size()-1-e;
			break;
		}
		if(s[a]=='%')
		b=3;
	}
	if(b==0)
	{
		stringstream IO;
		reverse(s.begin(),s.end());
		IO<<s;
		IO>>c;
		cout<<c;
		return 0;
	}
	if(b==1)
	{
		stringstream FIO,FIN,FOUT;
		str=s.substr(0,e);
		reverse(str.begin(),str.end());
		stri=s.substr(g,f);
		FIO<<str;
		FIO>>i;
		FIN<<stri;
		FIN>>j;
		FOUT<<j;
		FOUT>>_s;
		reverse(_s.begin(),_s.end());
		cout<<i<<"."<<_s;
		return 0;
	}
	if(b==2)
	{
		stringstream LIN,LIO;
		strin=s.substr(0,e);
		reverse(strin.begin(),strin.end());
		_strin=s.substr(g,f);
		reverse(_strin.begin(),_strin.end());
		LIN<<strin;
		LIN>>k;
		LIO<<_strin;
		LIO>>l;
		cout<<k<<"/"<<l;
		return 0;
	}
	if(b==3)
	{
		st=s.substr(0,s.size()-1);
		reverse(st.begin(),st.end());
		stringstream in;
		in<<st;
		in>>d;
		cout<<d<<"%";
		return 0;
	}
}
2023/7/28 19:27
加载中...