社区讨论

只过了8个点,求大神告诉我0怎么办

P1553数字反转(升级版)参与者 4已保存回复 7

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
7 条
当前快照
1 份
快照标识符
@mi4eqbr0
此快照首次捕获于
2025/11/18 18:04
4 个月前
此快照最后确认于
2025/11/18 18:04
4 个月前
查看原帖
CPP
#include<iostream>
#include<cstdio>                                      
#include<string>
using namespace std;
int main()
{
char str[10000];
int z=0,y,i,j=0,k=0,n,len=0,x,ji1,ji2,ji3,ji4;
gets(str);
for (i=0;str[i]!='\0';i++)
{   if (str[i]=='/') j=i;
    if (str[i]=='.') z=i;
    if (str[i]=='%') k=i;
    len++;
}
if (j!=0) n=j;
else if (z!=0) n=z;
else n=k;
if (n==0)
for (x=len-1;x>=0;x--)
{
    if (str[x]!='0' ) cout<<str[x];
}
else if (z!=0)
{
for (x=z-1;x>=0;x--)
{
    if (str[x]!='0') cout<<str[x];
}
cout<<'.';
for (y=len-1;y>=z+1;y--)
{
    if (str[y]!='0') cout<<str[y];
}
}
else if (j!=0)
{
for (x=j-1;x>=0;x--)
{
    if (str[x]!='0') cout<<str[x];
}
cout<<'/';
for (y=len-1;y>=j+1;y--)
{
    if (str[y]!='0') cout<<str[y];
}
}
else if (k!=0)
{
    for (x=k-1;x>=0;x--)
{
    if (str[x]!='0') cout<<str[x];
}
cout<<'%';
}
return 0;
}

回复

7 条回复,欢迎继续交流。

正在加载回复...