
【洛谷】P1106 删数问题
������������������
发布日期:2021-05-12 19:55:21
浏览次数:17
分类:精选文章
本文共 2628 字,大约阅读时间需要 8 分钟。
C++���������������������
������������������������������������������������������������������������������������������������������������������������
������������
���������������������������������
���������������
#include#include #include #include
���������������������������C++������I/O������������
������������
std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
������������������������������������������������������������������
���������������
freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);
���������������������������������������
���������������������
���������������������������������������������n������������������������
n += "0";
���������������������������������0������������
- ������������
- ������������������������������������������������������������������������������������������
- ���������������������������������������������
- ���������������
- ���������������������������������0������������������
- ������������
- ���������������������������������������������������0������
-
������������
������������������������������������������������ -
������������
��������������������������������������������������������������������� -
������������
������������������������������������������������������������������������������������
while (k--) { for (int i = 0; i < n.size() - 1; i++) { if (n[i] > n[i+1]) { n.erase(i, 1); // ��������� break; } }}
int check = 0, flag = 0;while (n[check] == '0') check++;
for (int i = check; i < n.size() - 1; i++) { cout << n[i]; flag = 1;}
������������
������������������
#include#include #include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); std::string n; int k; std::cin >> n >> k; n += "0"; while (k--) { for (int i = 0; i < n.size() - 1; i++) { if (n[i] > n[i+1]) { n.erase(i, 1); break; } } } int check = 0, flag = 0; while (n[check] == '0') check++; for (int i = check; i < n.size(); ++i) { if (n[i] != '0') { std::cout << n[i]; flag = 1; break; } } if (!flag) { std::cout << "0"; }}
������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
表示我来过!
[***.240.166.169]2025年04月05日 15时33分28秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Android Retrofit2.0 上传单张图片和多张图片
2021-05-10
iOS_Runtime3_动态添加方法
2021-05-10
Leetcode第557题---翻转字符串中的单词
2021-05-10
Problem G. The Stones Game【取石子博弈 & 思维】
2021-05-10
Unable to execute dex: Multiple dex files
2021-05-10
Java多线程
2021-05-10
Unity监听日记
2021-05-10
AndroidStudio跳到错误位置
2021-05-10
木马开发的基本理论基础(五)
2021-05-10
openssl服务器证书操作
2021-05-10
expect 模拟交互 ftp 上传文件到指定目录下
2021-05-10
linux系统下双屏显示
2021-05-10
PDF.js —— vue项目中使用pdf.js显示pdf文件(流)
2021-05-10
我用wxPython搭建GUI量化系统之最小架构的运行
2021-05-10
我用wxPython搭建GUI量化系统之Sizer布局管理与页面切换
2021-05-10
我用wxPython搭建GUI量化系统之多只股票走势对比界面
2021-05-10
我用wxPython搭建GUI量化系统之财务选股工具添加日历和排序
2021-05-10
2019年达观杯文本智能信息抽取挑战赛 四到十名队伍分享
2021-05-10
selenium+python之切换窗口
2021-05-10
重载和重写的区别:
2021-05-10