博客
关于我
杭电2081 手机短号
阅读量:710 次
发布时间:2019-03-21

本文共 755 字,大约阅读时间需要 2 分钟。

杭电2081

求11位数字后四位,输出时前置一位'6'+该数段即可

直接用char数组储存数字,依次输出即可。

AC代码解析

#include 
using namespace std;char a[100];int n;int main() { while (cin >> n) { for (int i = 0; i < n; i++) { cin >> a; // 单独处理第7位,拼接到输出中 cout << "6" << a[6]; //拼接后续各位数字 if (i == 6) break; cout << a[i] << a[i + 1] << a[i + 2] << a[i + 3]; } // 输出的重组数字 for (int j = n - 1; j >= 0; --j) { // 输出第7位之前,拼接"6" if (j == 6) { cout << "6" << a[7]; } //接下来的各位数字 else if (j < 6) { if (!alone) { cout << a[j] << a[j + 1]; } } } }}

以上是代码的完整实现,能够满足题目中对数字处理的要求。

转载地址:http://dbmez.baihongyu.com/

你可能感兴趣的文章
pytorch介绍-ChatGPT4o作答
查看>>
PP-PLL:基于概率传播的部分标签学习
查看>>
pytorch介绍
查看>>
pprint 排序字典但不是集合?
查看>>
pptp拨号上网
查看>>
ppt上的倒计时小工具_PPT中有哪些「看似很 LOW,实则惊艳」的小工具
查看>>
PPT添加视频的路径问题
查看>>
PPT美化插件 islide 安装过程问题“加载com加载项时运行出现错误”
查看>>
Prefix Tuning:详细解读Optimizing Continuous Prompts for Generation
查看>>
PreparedStatement 与Statement 的区别,以及为什么推荐使用 PreparedStatement ?
查看>>
PreparedStatement 查询 In 语句 setArray 等介绍。
查看>>
presentModalViewController显示半透明的一个view
查看>>
PresentViewController切换界面
查看>>
PyTorch之torch.utils.data.DataLoader解读
查看>>
PyTorch之DataLoader杂谈
查看>>
presto、druid、sparkSQL、kylin的对比分析
查看>>
Presto分布式大数据查询引擎
查看>>
Presto架构及原理
查看>>
Presto(一)集群部署
查看>>
Presto(二)开启安全认证
查看>>