int func(int n){ int i = 0,sum = 0; while(sum < n) sum += ++i; return i; } 求时间复杂度 A. O(logn) B. O(n^1/2) C. O(n) D. O(nlogn) ++i, i = 1,2,3,4,5,···,k。 ...
分类:
其他好文 时间:
2021-04-10 13:08:02
阅读次数:
0
1. 指定宽度对齐 说明: %-30s表示输出字符串,宽度30位,左对齐. %-15s用来指定第二列的,左对齐,宽度15. 两个百分号之间可以没有空格. 使用\n对每一行的输出加上换行符。 work]# awk -F: '{print "user:" $1"\t\tuid:" $3}' /etc/p ...
分类:
系统相关 时间:
2021-04-10 13:03:55
阅读次数:
0
#!/bin/bash APP_NAME="${0##*[\\/]}" APP_VERSION="1.0" #颜色定义 iSumColor=7 #颜色总数 cRed=1 #红色 cGreen=2 #绿色 cYellow=3 #××× cBlue=4 #蓝色 cFuchsia=5 #紫红色 cCyan ...
分类:
系统相关 时间:
2021-04-09 13:30:17
阅读次数:
0
做一个多功能计算器 欢迎使用计算器系统 int + int double + double 、 计算 n 的阶乘 计算 a的 n次方、 退出系统 import java.util.Scanner; public class Calculator { public static void main(S ...
分类:
编程语言 时间:
2021-04-09 12:50:24
阅读次数:
0
long long myPow(long long x, int n) { long long ans = 1; while(n){ if(n % 2 != 0){ ans *= x; ans %= modN; } x *= x; x %= modN; n /= 2; } return ans; } ...
分类:
其他好文 时间:
2021-04-08 13:55:01
阅读次数:
0
题目: Given any string of N (≥) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l ...
分类:
其他好文 时间:
2021-04-08 13:31:19
阅读次数:
0
sed编辑器:流编辑器(stream editor)。 vim:文本编辑器。 流编辑器会在编辑器处理数据之前基于预先提供的一组规则来编辑数据流。 sed编辑器的处理流程 读入一行数据 根据给出的编辑器命令匹配数据 按照命令修改流中的数据 将新的数据输出到STDOUT sed命令格式 sed opti ...
分类:
系统相关 时间:
2021-04-08 13:24:35
阅读次数:
0
方式一(将整数转换为字符串,在转换为字符数组): public boolean isPalindrome(int x) { if (x < 0) { return false; } char[] chars = new String(Integer.toString(x)).toCharArray( ...
分类:
其他好文 时间:
2021-04-08 13:10:24
阅读次数:
0
二叉树——102. 二叉树的层序遍历 题目: 思路: 就是层序遍历,一层层扫下去,然后通过队列去实现,一个队列先暂存这一层的所有结点,然后另一个队列通过push_back的方式,实现从左到右的访问。 代码: class Solution { public: vector<vector<int>> l ...
分类:
其他好文 时间:
2021-04-08 12:59:26
阅读次数:
0
比较for和while 代码比较复制代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 public class HelloWorld { public static void main(String[] args) { //使用while打印0到4 int i = ...
分类:
其他好文 时间:
2021-04-08 12:54:22
阅读次数:
0