当前位置:网站首页>Niuke net brush questions
Niuke net brush questions
2022-07-29 10:53:00 【A collection of old dreams 186】
Catalog
Fibonacci The sequence
subject :
answer :
#include<stdio.h> int main() { int a = 0; int b = 1; int c = a + b; int n = 0; scanf("%d", &n); while (1) { if (n == b) { printf("0\n"); break; } if (n < b) { if (abs(a - n) > abs(b - n)) { printf("%d", abs(b - n)); break; } else { printf("%d", abs(a - n)); break; } } c = a + b; a = b; b = c; } return 0; }
Replace blank space
subject :
【 Replace blank space 】 Please implement a function , Replace each space in a string with “%20”. for example , When the string is We Are Happy. The replaced string is We%20Are%20Happy.
answer :
class Solution { public: void replaceSpace(char* str, int length) { while (*str != '\n') { if (*str == ' '); int space = 0; space += 2; str++; } int end2 = length - 1; int end1 = length - 2 * space - 1; while (end1 < end2) { if (str[end1] == ' ') { str[end2] = '0'; end2--; str[end2] = '2'; end2--; str[end2] = '%'; end2--; } else { str[end2--] = str[end1--]; } } } };
边栏推荐
- LeetCode_ 1049_ Weight of the last stone II
- Using R-Pack premsim to predict microsatellite instability based on gene expression
- 重磅 | 2022 开放原子全球开源峰会在北京开幕
- Pyqt5 rapid development and practice 6.6 qformlayout & 6.7 nested layout & 6.8 qsplitter
- 基于flask实现的mall商城---用户模块
- Spark efficient data analysis 02, basic knowledge 13
- 专访 | 阿里巴巴首席技术官程立:云 + 开源共同形成数字世界的可信基础
- 『知识集锦』一文搞懂mysql索引!!(建议收藏)
- LeetCode_278_第一个错误的版本
- ES6-箭头函数this指向
猜你喜欢

JVM知识点详细整理(长文警告)

QT工程基本构建

Watch the open source summit first | quick view of the sub Forum & Activity agenda on July 29

AI模型风险评估 第2部分:核心内容

Kunlunbase instruction manual (II) best practices for peer-to-peer deployment

How to synchronize when the primary and sub warehouses are modified?

Why use markdown to write?

Review of the 16th issue of HMS core discovery | play with the new "sound" state of AI with tiger pier

Kunlunbase instruction manual (IV) real time synchronization of data from Oracle to kunlunbase

开源峰会抢先看 | 7 月 29 日分论坛 & 活动议程速览
随机推荐
VMware: use commands to update or upgrade VMware esxi hosts
学习R语言这几本电子书就够了!
sql join中on条件后接and和where
Function comparison between report control FastReport and stimulus soft
Ggdag draw DAG and cause and effect diagram
阿里架构师耗时一年整理的《Lucene高级文档》,吃透你也是大厂员工!
Pyqt5 rapid development and practice 6.6 qformlayout & 6.7 nested layout & 6.8 qsplitter
2022cuda summer training camp Day6 practice
2.安装MySQL
开源峰会抢先看 | 7月29日分论坛&活动议程速览
会议OA项目(五)---- 会议通知、反馈详情
R 语言 Monte Carlo方法 和平均值法 计算定积分, 考虑随机投点法,计算在置信度0.05, 要求为ϵ=0.01 , 所需要的试验次数
Adcode city code in Gaode map API
若依如何实现添加水印功能
Spark高效数据分析02、基础知识13篇
If distributed file storage is realized according to integrated Minio
Svn revision keyword
Roots of equations in R language dichotomy and Newton iteration
『知识集锦』一文搞懂mysql索引!!(建议收藏)
Software testing dry goods


