当前位置:网站首页>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 !
边栏推荐
- I want to ask you, where is a better place to open an account in Dongguan? Is it safe to open a mobile account?
- Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)
- Research Report on the overall scale, major manufacturers, major regions, products and applications of swivel chair gas springs in the global market in 2022
- [question brushing diary] classic questions of dynamic planning
- How to realize the function of detecting browser type in Web System
- Driverless learning (4): Bayesian filtering
- Welfare | Pu Aries | liv heart co branded Plush surrounding new products are on the market!
- Sometimes only one line of statements are queried, and the execution is slow
- Research Report on the overall scale, major manufacturers, major regions, products and applications of building automation power meters in the global market in 2022
- rwctf2022_ QLaaS
猜你喜欢

I drew a Gu ailing with characters!
![[internship] solve the problem of too long request parameters](/img/42/413cf867f0cb34eeaf999f654bf02f.png)
[internship] solve the problem of too long request parameters
![[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
![[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)

pytorch 模型保存的完整例子+pytorch 模型保存只保存可训练参数吗?是(+解决方案)

Data preparation for behavior scorecard modeling

5 environment construction spark on yarn

Customized Huawei hg8546m restores Huawei's original interface

B-end e-commerce - reverse order process

Resunnet - tensorrt8.2 Speed and Display record Sheet on Jetson Xavier NX (continuously supplemented)
随机推荐
Makefile: usage of control functions (error, warning, info)
Driverless learning (4): Bayesian filtering
【Kubernetes系列】kubeadm reset初始化前后空间、内存使用情况对比
Summary of interview experience, escort your offer, full of knowledge points
Implementing yolox from scratch: dataset class
I did a craniotomy experiment: talk about macromolecule coding theory and Lao Wang's fallacy from corpus callosum and frontal leukotomy
Database schema notes - how to choose the right database in development + who invented relational database?
I would like to ask what securities dealers recommend? Is it safe to open a mobile account?
Is it safe to buy funds on securities accounts? Where can I buy funds
Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)
Activation function - relu vs sigmoid
kernel_ uaf
JS modularization
数据库模式笔记 --- 如何在开发中选择合适的数据库+关系型数据库是谁发明的?
Function, function, efficiency, function, utility, efficacy
Wu Enda's machine learning mind mapping insists on clocking in for 23 days - building a knowledge context, reviewing, summarizing and replying
[12] the water of the waves is clear, which can wash my tassel. The water of the waves is muddy, which can wash my feet
【871. 最低加油次数】
[cloud native topic -50]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware MySQL microservice deployment process
Redis sentinel cluster working principle and architecture deployment # yyds dry goods inventory #