首页 > 其他 > 详细

1125 - A == B ?——中级

时间:2020-01-18 09:58:28      阅读:68      评论:0      收藏:0      [点我收藏+]
 1 #include<iostream>
 2 #include<string>
 3 using namespace std;
 4 string s[2];
 5 void shape(int n){
 6     int i,pj=0,len=s[n].length(),p=0;
 7     if(s[n][0]==-)
 8         p=1;
 9     for(i=0;i<len;i++)
10         if(s[n][i]==.){
11             pj=1;
12             break;
13         }
14     if(pj){
15         while(s[n][len-1]==0)
16             s[n].erase(--len,1);
17         if(s[n][len-1]==.)
18             s[n].erase(--len,1);
19     }
20     while(s[n][p]==0){
21         if(len>p+1){
22             s[n].erase(p,1);
23             len--;
24         }
25         else
26             break;
27     }
28     if(s[n][p]==.)
29         s[n].insert(p,"0");
30     if(s[n]=="-0")
31         s[n]="0";
32 }
33 int main(){
34     ios::sync_with_stdio(0);
35     cin.tie(0);cout.tie(0);
36     while(cin>>s[0]>>s[1]){
37         shape(0);
38         shape(1);
39         if(s[0]==s[1])
40             puts("YES");
41         else
42             puts("NO");
43     }
44     return 0;
45 }

1125 - A == B ?——中级

原文:https://www.cnblogs.com/stelayuri/p/12208042.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!