题目 解法 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); int res = 0; while(num !=0 ){ if( (num&1) == 1){ res++; } //无符号右移 num >>>= 1; } System.o…
牛客网华为机试题之Python解法 第1题 字符串最后一个单词的长度 a = input().split(" ") print(len(a[-1])) 第2题 计算字符个数 a = input() b = input() print(a.lower().count(b.lower())) 第3题 明明的随机数 while True: try: num = int(input()) data = [] for i in range(num): data.append(int(input(…