01 2017 档案
摘要:Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". 1.直接调用c++ STL reverse(s.begi
阅读全文
摘要:Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the numbe
阅读全文
摘要:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n]
阅读全文
摘要:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length
阅读全文
摘要:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: Example 1: Exa
阅读全文
摘要:The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calcul
阅读全文
摘要:一个人的夜明珠丢了,于是他开始四处寻找。有一天,他来到了山上,看到有三个小屋,分别为1号、2号、3号。从这三个小屋里分别走出来一个女子,1号屋的女子说:“夜明珠不在此屋里。”2号屋的女子说:“夜明珠在1号屋内。”3号屋的女子说:“夜明珠不在此屋里。” 这三个女子,其中只有一个人说了真话,那么,谁说了
阅读全文
摘要:姐姐上街买菜回来后,就随手把手里的一些零钱放在了抽屉里,可是,等姐姐下午再去拿钱买菜的时候发现抽屉里的零钱没有了,于是,她就把三个妹妹叫来,问她们是不是拿了抽屉里的零钱,甲说:“我拿了,中午去买零食了。”乙说:“我看到甲拿了。”丙说:“总之,我与乙都没有拿。”这三个人中有一个人在说谎,那么到底谁在说
阅读全文
摘要:赵女士买了一些水果和小食品准备去看望一个朋友,谁知,这些水果和小食品被他的儿子们偷吃了,但她不知道是哪个儿子。,为此,赵女士非常生气,就盘问4个儿子谁偷吃了水果和小食品。老大说道:“是老二吃的。”老二说道:“是老四偷吃的。”老三说道:“反正我没有偷吃。”老四说道:“老二在说谎。”这4个儿子中只有一个
阅读全文
摘要:设计函数int sqrt(int x),计算x的平方根。 格式: 输入一个数x,输出它的平方根。直到碰到结束符号为止。 千万注意:是int类型哦~ 输入可以如下操作: while(cin>>x) 或者 while(scanf("%d", &x) != EOF) 设计函数int sqrt(int x)
阅读全文