当前位置:网站首页>Spend more time with your computer on this special holiday, HHH
Spend more time with your computer on this special holiday, HHH
2022-07-02 21:01:00 【*Yiiiiiiiiiiiiii】
Input number n , Print out from... In order 1 To the biggest n A decimal number . Such as input 3 , Then print out 1、2、3 Up to the biggest 3 digit 999 .
- Instead of printing, return a list of integers
- n As a positive integer
OJ link 【 Question no. of niuke.com : JZ17 Print from 1 To the biggest n digit 】
Example :
Input :1
Return value :[1,2,3,4,5,6,7,8,9]
int* printNumbers(int n, int* returnSize )
{
}
If there is no interface provided by the above input , We don't need to apply for space dynamically !
First of all, be clear n The largest number of digits , It's actually 10^n - 1
1 digit : 10^1 - 1
2 digit : 10^2 - 1
3 digit : 10^3 - 1
...( call pow function :pow(10,n)-1)
The actual code is as follows :
#include<stdio.h>
#include<math.h>
int main()
{
int n,i=0;
scanf("%d",&n);
for(i=1;i<=(pow(10,n)-1);i++)
{
if(i==(pow(10,n)-1))
{
printf("%d",i);
}
else
printf("%d,",i);
}
return 0;
} Operation of the :
Because this code is relatively simple , So I won't describe it in detail here .
premium : According to the interface provided by Niuke online , Implement this interface to complete the requirements of the topic
After this is clear, the dynamic application space , Just fill in the value , It should be noted that the array subscript is from 0 Start , And the value from 1 Start
int* printNumbers(int n, int* returnSize )
{
*returnSize = pow(10, n) - 1; // Determine the maximum number
int *arr = (int *)malloc(sizeof(int)*(*returnSize));// Apply for space of sufficient size
for (int i = 0; i < *returnSize; i++)
{
arr[i] = i+1;// Subscript from 0 Start , And the value from 1 Start
}
return arr;
}1946 year 2 month 14 Japan , The world's first general-purpose computer was born at the University of Pennsylvania , Please spend more time with your computer on this special holiday , Ha ha ha ha ha ha ha !
边栏推荐
- GCC: Graph Contrastive Coding for Graph Neural NetworkPre-Training
- 「 工业缺陷检测深度学习方法」最新2022研究综述
- Go cache of go cache series
- Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of signal distributors in the global market in 2022
- mysql
- 7. Build native development environment
- [QT] QPushButton creation
- Cs5268 perfectly replaces ag9321mcq typec multi in one docking station solution
- Implementing yolox from scratch: dataset class
- Interested parties add me for private chat
猜你喜欢

疫情封控65天,我的居家办公心得分享 | 社区征文

rwctf2022_ QLaaS

Resunnet - tensorrt8.2 Speed and Display record Sheet on Jetson Xavier NX (continuously supplemented)

Properties of expectation and variance

【QT】QPushButton创建
![[cloud native topic -50]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware MySQL microservice deployment process](/img/e6/1dc747de045166f09ecdce1c5a34b1.jpg)
[cloud native topic -50]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware MySQL microservice deployment process

Taiwan SSS Xinchuang sss1700 replaces cmmedia cm6533 24bit 96KHz USB audio codec chip

The metamask method is used to obtain account information

Write the content into the picture with type or echo and view it with WinHex
![[fluent] dart technique (independent main function entry | nullable type determination | default value setting)](/img/cc/3e4ff5cb2237c0f2007c61db1c346d.jpg)
[fluent] dart technique (independent main function entry | nullable type determination | default value setting)
随机推荐
mysql
Research Report on the overall scale, major manufacturers, major regions, products and applications of capacitive voltage transformers in the global market in 2022
Lantern Festival, come and guess lantern riddles to win the "year of the tiger Doll"!
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of the inverted front fork of the global market in 2022
Review of the latest 2022 research on "deep learning methods for industrial defect detection"
AMD's largest transaction ever, the successful acquisition of Xilinx with us $35billion
Write the content into the picture with type or echo and view it with WinHex
Codeworks global round 19 (CF 1637) a ~ e problem solution
Complete example of pytorch model saving +does pytorch model saving only save trainable parameters? Yes (+ solution)
GCC: Graph Contrastive Coding for Graph Neural NetworkPre-Training
API documentation tool knife4j usage details
Customized Huawei hg8546m restores Huawei's original interface
pytorch 模型保存的完整例子+pytorch 模型保存只保存可训练参数吗?是(+解决方案)
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of multi-channel signal conditioners in the global market in 2022
Send blessings on Lantern Festival | limited edition red envelope cover of audio and video is released!
I drew a Gu ailing with characters!
I want to ask you, where is a better place to open an account in Dongguan? Is it safe to open a mobile account?
Driverless learning (III): Kalman filter
【Hot100】23. Merge K ascending linked lists
[QT] QPushButton creation