当前位置:网站首页>1317. convert an integer to the sum of two zero free integers
1317. convert an integer to the sum of two zero free integers
2022-06-27 05:55:00 【Mr Gao】
1317. Convert an integer to the sum of two nonzero integers
「 Zero free integer 」 Is in the decimal representation It doesn't contain any 0 The positive integer .
Give you an integer n, Please return one A list of two integers [A, B], Satisfy :
A and B Are zero free integers
A + B = n
The problem data ensures that there is at least one effective solution .
If there are multiple effective solutions , You can return any of them .
Example 1:
Input :n = 2
Output :[1,1]
explain :A = 1, B = 1. A + B = n also A and B The decimal representation of does not contain any 0 .
Example 2:
Input :n = 11
Output :[2,9]
Example 3:
Input :n = 10000
Output :[1,9999]
Example 4:
Input :n = 69
Output :[1,68]
Example 5:
Input :n = 1010
Output :[11,999]
This question is comparatively simple , The solution code is as follows :
/** * Note: The returned array must be malloced, assume caller calls free(). */
bool f(int n){
while(n){
if(n%10==0){
return false;
}
n=n/10;
}
return true;
}
int* getNoZeroIntegers(int n, int* returnSize){
int *re=(int *)malloc(sizeof(int)*2);
int i;
for(i=1;i<n;i++){
if(f(n-i)&&f(i)){
re[0]=i;
re[1]=n-i;
*(returnSize)=2;
return re;
}
}
return re;
}
边栏推荐
- Neon optimization 1: how to optimize software performance and reduce power consumption?
- 双位置继电器RXMVB2 R251 204 110DC
- Experience oceanbase database under win10
- 软件测试年终总结报告模板
- 《汇编语言-王爽》第3章笔记及实验
- 1317. 将整数转换为两个无零整数的和
- How win 10 opens the environment variables window
- Senior [Software Test Engineer] learning route and necessary knowledge points
- Matlab quickly converts two-dimensional coordinates of images into longitude and latitude coordinates
- Unity中跨平台获取系统音量
猜你喜欢
Navigation [machine learning]
[FPGA] realize the data output of checkerboard horizontal and vertical gray scale diagram based on bt1120 timing design
免费的 SSH 和 Telnet 客户端PuTTY
树莓派4B上运行opcua协议DEMO接入kubeedge
Leetcode99 week race record
LeetCode-515. Find the maximum value in each tree row
openstack实例重启状态就会变成错误处理方法,容器搭建的openstack重启计算节点compute服务方法,开机提示Give root password for maintenance处理方法
Mechanical transcoding journal [17] template, STL introduction
Gao Xiang slam14 lecture - note 1
汇编语言-王爽 第13章 int指令-笔记
随机推荐
【Cocos Creator 3.5.1】input.on的使用
js实现双向数据绑定
Gao Xiang slam14 lecture - note 1
【FPGA】UART串口_V1.1
Webrtc Series - Network Transport 7 - ice Supplement nominations and ice Modèle
软件测试年终总结报告模板
leetcode299周赛记录
Database - index
块级元素&行内元素
Win 10 如何打开环境变量窗口
The form verifies the variables bound to the V-model, and the solution to invalid verification
双位置继电器DLS-34A DC0.5A 220VDC
Nlp-d62-nlp competition d31 & question brushing D15
程序猿学习抖音短视频制作
【FPGA】基于bt1120时序设计实现棋盘格横纵向灰阶图数据输出
汇编语言-王爽 第13章 int指令-笔记
Asp. Net core6 websocket simple case
Machunmei, the first edition of principles and applications of database... Compiled final review notes
expect脚本中使用scp命令的方法,expect脚本中scp命令获取不了值的问题完美解决方法
C language implementation timer