刚刚看到一个面试题:写一个函数,输入int型,返回整数逆序后的字符串.如:输入123,返回"321". 要求必须用递归,不能用全局变量,输入必须是一个參数.必须返回字符串." package cn.baokx; public class Test { public static void main(String[] args) { System.out.println(fun(12345678)); } public static String fun(int num){ i
You enter a URL into the browser输入一个url地址 The browser looks up the IP address for the domain name浏览器查找域名的ip地址(浏览器缓存→系统缓存→路由器缓存→ISP DNS缓存→从根域名服务器递归搜索) The browser sends a HTTP request to the web server浏览器给web服务器发送一个HTTP请求 The facebook server responds
//整数数组的定义,然后输入一个整数x,假定X不在这个数组,返回小于X位置的最大数目i而超过X位置的最小数目j: //如果X在该阵列,返回位置的阵列中的数. 资源: #include<iostream> using namespace std; void main() { int array[]={1,2,3,4,5,6,7,89,45,32,56,78,12,43,90,19};//16个数字 int x; int max=array[0]; int min=array[0]; int ma
import itertools str = input('请输入一个字符串:') lst = [] for i in range(1, len(str)+1): lst1 = [''.join(x) for x in itertools.permutations(str, i)] lst += lst1 print(lst) 主要使用的itertools库
如何输入一个字符串,得到一个唯一的hashcode? 例子如下: package main import ( "fmt" "hash/crc32" ) // String hashes a string to a unique hashcode. // // crc32 returns a uint32, but for our use we need // and non negative integer. Here we cast to an integer /
函数可以没有返回值案例,编写一个函数,从终端输入一个整数,打印出对应的金字塔 import scala.io.StdIn object work02 { def main(args: Array[String]): Unit = { println("请输入一个数") var num:Int=StdIn.readInt() val pige=(num:Int)=>{ for (i<-1 to num){ for (j<-1 to num-i){ print("