分析

给出两个串 从末尾开始对齐 每位对齐后,每一位 遍历

如果 第一串 的那位 < 第二串 的 那么 第一串的那位 就删去

如果 等于 两位 都保留

如果 大于 那么 保留 第二串的 那位

如果 最后 删完了 那一串 就输出 YODA

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> using namespace std;
typedef long long LL; const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6; const int INF = 0x3f3f3f3f;
const int maxn = 1e9 + 5;
const int MOD = 1e9 + 7; int main()
{
string s1, s2;
string c1 = "", c2 = "";
cin >> s1 >> s2;
int len1 = s1.size(), len2 = s2.size();
int i, j;
for (i = len1 - 1, j = len2 - 1; i >= 0 && j >= 0; i--, j--)
{
if (s1[i] < s2[j])
c2 += s2[j];
else if (s1[i] == s2[j])
{
c1 += s1[i];
c2 += s2[j];
}
else
c1 += s1[i];
}
if (i >= 0)
{
for ( ; i >= 0; i--)
c1 += s1[i];
}
if (j >= 0)
{
for ( ; j >= 0; j--)
c2 += s2[j];
}
if (c1.size())
{
for (i = c1.size() - 1; i >= 0; i--)
{
if (c1[i] != '0' || (c1[i] == '0' && i == 0))
{
cout << c1[i];
break;
}
}
for (i-- ; i >= 0; i--)
cout << c1[i];
}
else
cout << "YODA";
printf("\n");
if (c2.size())
{
for (i = c2.size() - 1; i >= 0; i--)
{
if (c2[i] != '0' || (c2[i] == '0' && i == 0))
{
cout << c2[i];
break;
}
}
for (i-- ; i >= 0; i--)
cout << c2[i];
}
else
cout << "YODA";
printf("\n");
}

最新文章

  1. asp.net 各种路径
  2. SNS网站成功原因剖析_完结
  3. php获取当前页面的完整url
  4. js练习-控制div属性
  5. SG 复习全部 (全部SG 总览)
  6. VMware Workstation 10.0.0.1295980 CN
  7. Azure PowerShell 1.0.0以上版本在中国Azure使用的注意事项
  8. android 登陆案例
  9. Linux下Apache与Tomcat的完全分布式集群配置(负载均衡)
  10. Merge into的使用具体解释-你Merge了没有
  11. mybatis0205 一对多查询 复杂
  12. ueditor 文本编辑器
  13. Cytoscape源码下载地址和编译办法
  14. Nginx 一个高性能的HTTP和反向代理服务器
  15. 如何用ABP框架快速完成项目(6) - 用ABP一个人快速完成项目(2) - 使用多个成熟控件框架
  16. C# % 和 /
  17. Redis 保护模式
  18. 5-[HTML]-body常用标签2
  19. spring基础-01
  20. 自定义经纬度索引(非RTree、Morton Code[z order curve]、Geohash的方式)

热门文章

  1. C语言 | 计算器实现(中缀表示法/后缀表示法)
  2. DICOM医学图像处理:WEB PACS初谈二,图像的传输
  3. oracle经常使用函数(1)
  4. C#代码用法
  5. Mac下安装LNMP(Nginx+PHP5.6)环境(转)
  6. Lua学习十----------Lua数组
  7. Python读取文件文件夹并检索
  8. 第二章:核心C#
  9. applicationContext-XXX.xml和XXX-servlet.xml的区别
  10. linux heads分析(转)