当前位置:网站首页>[code hoof set novice village question 600] formatted input and output, using 0 to replace the completed space
[code hoof set novice village question 600] formatted input and output, using 0 to replace the completed space
2022-07-19 13:38:00 【Sandm *】
Topic link :
Their thinking :
Because the title requires to be in front of the output value , If there are extra spaces, use 0 To make up for
Complement method :
Try to use C In language printf ( ) function ,
Because you can format and control the format of input and output ,
and C++ The input / output stream in does not have this function ,
Although it can be achieved ,
But relatively speaking, it is more complicated
namely :
%0nd
there 0 Is to use numbers 0 Instead of spaces
Reference code :
#include<bits/stdc++.h>
using namespace std;
int main( )
{
int year = 0,month = 0,date = 0;
//cin >> month >> "/" >> date >> "/" >> year ;
/* You cannot use the above method to input / */
scanf("%d/%d/%d",&month,&date,&year);
printf("%04d%02d%02d",year,month,date);
return 0;
}
边栏推荐
- Hello, everyone. How to synchronize binlog in real time before the database starts? Is there a good scheme
- Onvif protocol related: 2.1.3 get the stream address in none mode
- 【腾讯蓝鲸】第七届 7·24 运维日节日祝福送上~ 快来许愿~
- Google Earth Engine——1992—至今混合坐标海洋模型、水温和盐度(全球海洋数据集HYCOM)
- Module 7 (Architecture Design of King glory mall)
- 命令行的一些常用操作命令及常见错误的解决办法
- 【7.9】代码源 -【选数】【序列操作】【Minimum Or Spanning Tree】
- Use golang to correctly process the IP data of the five major Internet registration agencies
- Helloword and led: a quick start to Hongmeng device development -- Huawei cloud 14 day Hongmeng device development practical learning notes Chapter 2
- Realize automatic logging
猜你喜欢
Advanced C language -- character function and string function
[pyGame learning notes] 6 Cursor mouse cursor
【码蹄集新手村 600 题】科学计数法的实现方式,输出指数形式
torch. utils. data. Dataloader description
(pc+wap) dream weaving template clothing dress website
[Tencent blue whale] the seventh 7.24 operation and maintenance day holiday greetings ~ come and make a wish~
Responsive dream weaving template wine cellar website
【js逆向爬虫】-有道翻译js逆向实战
ONVIF Protocol Related: 4.1.3 WS - username token Method get capture d'écran URL
Flutter 使用 AnimatedSwitcher 做场景切换
随机推荐
npm err! ant-design- [email protected] build: `umi build`
ArrayList underlying analysis
565. Array nesting
AcWing第 60 场周赛
[understanding of opportunity-46]: Guiguzi - Chapter 10 - schemer, meaning of wisdom
【码蹄集新手村 600 题】科学计数法的实现方式,输出指数形式
基于PMOS的过压保护(OVP)电路仿真
Codeforces Round #808 (Div. 2)ABCD
Perl command batch replaces some contents in the file
Running node for getting started with eth
eth入门之运行节点
STL string复制比较
Li Kou 198-213 looting Ⅰ, Ⅱ - Dynamic Planning
力扣第 302 场周赛
Onvif protocol related: 4.1.4 WS username token method to obtain the stream address
【刷题记录】13. 罗马数字转整数
Wrong again, byte alignment and the use of pragma pack
Codeforce:a. doremy's IQ [reverse greed]
[pumpkin Book ml] (task2) mathematical derivation of linear model (least squares estimation, generalized Rayleigh quotient, maximum likelihood estimation, etc.)
LeetCode 0118. Yanghui triangle