|
- #include<iostream>
- #include<cstdio>
- using namespace std;
- char s[20],k[20];
- int i,j,m=0,n=0,a=0,type=0;
- int main()
- {
- cin>>s;
- while(s[j]!=0)j++;
- for(i=0;i<j;i++)
- {
- if(s[i]=='.')type=1;
- if(s[i]=='/')type=2;
- if(s[i]=='%')type=3;
- }
- if(type==0)
- {
- for(i=0; i<j; i++)
- k[i]=s[j-i-1];
- n=0;
- while(k[n]=='0')n++;
- if(n==j)cout<<"0";
- else for(i=n;i<j;i++)
- cout<<k[i];
- }
- if(type==1)
- {
- while(s[m]!='.')m++;
- for(i=0;i<m;i++)k[i]=s[m-i-1];
- n=0;
- while(k[n]=='0')n++;
- if(n==m)cout<<"0";
- else for(i=n;i<m;i++)cout<<k[i];
- cout<<".";
- for(i=m;i<j-1;i++)k[i]=s[j-i+m-1];
- a=0;
- while(k[j-2-a]=='0')a++;
- if(a>=(j-m)-1)cout<<"0";
- else for(i=m;i<j-a-1;i++)cout<<k[i];
-
- }
- if(type==2)
- {
- while(s[m]!='/')m++;
- for(i=0;i<m;i++)k[i]=s[m-i-1];
- n=0;
- while(k[n]=='0')n++;
- if(n==m)cout<<"0";
- else for(i=n;i<m;i++)cout<<k[i];
- cout<<"/";
- for(i=m;i<j-1;i++)k[i]=s[j-i+m-1];
- a=m;
- while(k[a]=='0')a++;
- for(i=a;i<j-1;i++)cout<<k[i];
- }
- if(type==3)
- {
- while(s[m]!='%')m++;
- for(i=0;i<m;i++)k[i]=s[m-i-1];
- while(k[n]=='0')n++;
- if(n==(j-1))cout<<"0";
- else for(i=n;i<m;i++)cout<<k[i];
- cout<<"%";
- }
- return 0;
- }
复制代码 |
|