社区讨论
#5#19WA,已开unsigned
P1553数字反转(升级版)参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @lz18ntry
- 此快照首次捕获于
- 2024/07/25 20:17 2 年前
- 此快照最后确认于
- 2024/07/25 21:08 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
string input;
long long front=0,back=0;
char type;
int cnt;
bool b=0;
void cut(){
int time=0;
for(int i=0;i<input.length();i++){
if(input[i]<'0'||input[i]>'9') {
type=input[i];
cnt=i;
break;
}
front+=(input[i]-'0')*pow(10,time);
time++;
}
time=0;
for(int j=cnt+1;j<input.length();j++){
back+=(input[j]-'0')*pow(10,time);
time++;
}
}
void sub0(){
while(back%10==0)
back/=10;
}
int main(){
cin>>input;
cut();
if(type=='\0') {
for(int i=input.length()-1;i>=0;i--){
if(input[i]!='0') b=1;
if(b) cout<<input[i];
}
}
else if(type=='%') cout<<front<<"%";
else if(type=='.'){
if(back!=0) sub0();
cout<<front<<type<<back;
}
else cout<<front<<type<<back;
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...