90,第九和第十测试点错了,求救
查看原帖
90,第九和第十测试点错了,求救
811336
ghost202212904336楼主2022/11/9 20:33
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100];
	int i,n,behind=-1,l,note=-1;
	gets(s);
	l=strlen(s);
	n=l-1;
	for(i=0;i<l;i++)
	{
		if(s[i]=='.'||s[i]=='/'||s[i]=='%')
		{
			behind=i+1;break;
		}
		else
		{
			note++;
		}
	}
	while(note>0&&s[note]=='0')
	{
		note--;
	}
	for(i=note;i>=0;i--)
	{
		printf("%c",s[i]);
	}
	if(behind!=-1)
	{
		if(s[behind-1]=='.')
		{
			printf(".");
			while(behind>i&&s[behind]=='0')
	            behind++;
	        for(i=l-1;i>=behind;i--)
	        {
	   	        printf("%c",s[i]);
	        }
		}
		
		if(s[behind-1]=='/')
		{
			printf("%c",s[behind-1]);
			while(n>0&&s[n]=='0')
			    n--;
			for(i=n;i>=behind;i--)
			{
				printf("%c",s[i]);
			}
		}
		
		if(s[behind-1]=='%')
		{
			printf("%c",s[behind-1]);
		}
    }
	
	return 0;
}
2022/11/9 20:33
加载中...