当前位置:网站首页>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;
}
边栏推荐
- Mechanical transcoding journal [17] template, STL introduction
- Opencv实现对象跟踪
- Gao Xiang slam14 lecture - note 1
- 30个单片机常见问题及解决办法!
- Unity中跨平臺獲取系統音量
- openresty使用文档
- Niuke practice 101-c reasoning clown - bit operation + thinking
- Senior [Software Test Engineer] learning route and necessary knowledge points
- 【QT小记】QT中正则表达式QRegularExpression的基本使用
- 双位置继电器JDP-1440/DC110V
猜你喜欢

30 SCM common problems and solutions!

cpu-z中如何查看内存的频率和内存插槽的个数?

块级元素&行内元素

双位置继电器RXMVB2 R251 204 110DC

Double position relay jdp-1440/dc110v

C Primer Plus 第11章_字符串和字符串函数_代码和练习题

My opinion on test team construction

IAR systems fully supports Centrino technology 9 series chips

Basic concepts of neo4j graph database

Edge loads web pages in IE mode - edge sets ie compatibility
随机推荐
《汇编语言-王爽》第3章笔记及实验
Implementation of easyexcel's function of merging cells with the same content and dynamic title
C语言练手小项目(巩固加深知识点理解)
How JQ gets the ID name of an element
Add widget on qlistwidgetitem
WebRTC系列-網絡傳輸之7-ICE補充之提名(nomination)與ICE_Model
Junda technology - centralized monitoring scheme for multi brand precision air conditioners
Edge loads web pages in IE mode - edge sets ie compatibility
树莓派4B上运行opcua协议DEMO接入kubeedge
Two position relay xjls-8g/220
Two position relay hjws-9440
【QT小作】使用结构体数据生成读写配置文件代码
Luogu p2939 [usaco09feb]revamping trails G
Wechat applet refreshes the current page
Two position relay rxmvb2 r251 204 110dc
数据库-索引
How win 10 opens the environment variables window
MATLAB快速将影像的二维坐标转换为经纬度坐标
IAR systems fully supports Centrino technology 9 series chips
leetcode298周赛记录