Java program questions

Excerpt from: http://www.cnblogs.com/forlina/archive/2011/08/03/2126292.html   1. Complete quick sorting and bubble sorting of array int [] a = {100,40,60,87,34,11,56,0};

  2. The algorithm of half search is used to query a number in the array;

 3.在中文环境下,有字符串,将其每个字节的数据相加求和。 
 4.将一个数组中值=0的项去掉,将不为0的值存入一个新的数组,比如: 
  int a[]={1,3,4,5,6,7,5}; 
  生成的新数组为: 
  int b[]={1,5} 
 5.定义10个长度的Student数组,将10个Student对象的年龄全部加1,然后把10个Student对象的详细信息逐行打印出来(数组和ArrayList实现)。 
 6.有工人,农民,教师,科学家,服务生,其中,工人,服务生只有基本工资.教师除基本工资外,还有课酬(元/天),科学家除基本工资外,还有年终奖,请你写出相关类,
  将各种类型的员工的全年工资打印出来;

 7. Create a complex class complex and perform mathematical operations on the complex. The complex has the following format:

  RealPart+ImaginaryPart*I

Where I is the square root of - 1.

The requirements are as follows:

(1) use floating-point variables to represent the private data of this class. Two construction methods are provided, one for the initialization of the object when this class is declared, and the other is a parameterless construction method with default value.

(2) provide the operation methods of addition, subtraction and multiplication of two complex numbers.

(3) print the complex number according to format (a, b), where a is the real part and B is the imaginary part.

 8.实现圆类circle,包含相关的成员变量和成员方法。从圆类派生出圆柱类cylinder。根据建立的两个类,从键盘输入5个圆的半径,5个圆柱的半径和高度,
  并分别是输出5个圆的面积,5个圆柱的体积。

9. Enter an integer and find the sum of each number in the integer

10. Write a Java application. The requirements are as follows:

(1) declare a variable of string class and initialize the value "Hello world".

(2) use a method of string class to split the value of the above variable into two strings: "hello" and "world"

And print out.

(3) convert the variable "hello" to uppercase and "world" to lowercase and print out.

(4) declare a variable of string class and initialize the value "20100110".

(5) convert the value of the above variable into the form of printout on January 10, 2010.

11. Program function: find s = 1 + 3 + 5 + 7 + Until s > 2000.

12. Program function: calculate s = 2+ 4!+ 8!。 (first, define a function whose function is to find the factorial of any number)

13. Program function: find the number of numbers between 200 and 400 that can be divided by 3 but cannot be divided by 7.

14. Program function: find the number of three digits that can be divided by 3 and have at least one digit of 5.

15. Program function: among the three odd numbers, the remainder obtained by dividing the sum of one digit number and ten digit number by 10 is the number of hundreds of digits.

16. Solve the Baima Baiwa ancient problem. There are 100 horses, ponies and foals, carrying 100 tiles. One horse carries three, one pony carries two, and two foals carry one. All three horses carry them at one time. How many combinations are there?

17. Program function: find all prime numbers between 100-200

18. Program function: output the number of daffodils (the so-called daffodils number refers to a three digit decimal number, and the sum of the cubes of the numbers is equal to the number itself.

For example, 153 is a daffodil number, because 1 ^ 3 + 5 ^ 3 + 3 ^ 3 = 153)

19. Program function: the monkey picked several peaches on the first day, ate half of them immediately and one more, and ate the rest half and one more the next day; By analogy, only one remains on the 10th day. Ask how many peaches you picked on the first day.

20. Program function: a two digit positive integer. If its single digit is exchanged with ten digits, the generated number is called its exchange number. For example, 28 is the exchange number of 82. Given a two digit positive integer 46, please find another two digit integer so that the sum of the two numbers is equal to the sum of their respective transpositions. How many other double digits are there.

21. Program function: find the sum of squares of numbers between 1 and 200 that can be divided by 7.

22. Program function: sum the square roots of 1 ~ 99 and output the results. (two decimal places are reserved)

23. Program function: find the number of positive integers between [351432] that can neither be divided by 3 nor 8.

24. Program function: it is known that 24 has 8 positive integer factors (i.e. 1,2,8,12,24), and 24 is exactly divided by its factor number 8. How many such numbers are there between [100300].

25. Program function: if the sum of all factors of an integer n is equal to the multiple of N, then n is called multi factor complete number, such as number 28, and the sum of factors 1 + 2 + 4 + 7 + 14 + 28 = 56 = 2 * 28,28 is multi factor complete number. Find how many multi factor complete numbers there are between [1200].

26. Procedure function: China's GNP this year is 4560 billion yuan. If it grows at an annual growth rate of 9% in the future, how many years will it be possible to double the GNP?

27. Program function: a three digit number meets the following conditions: (1) the three digits are different; (2) This number is equal to the cubic sum of its digits. Find the number of three digits.

28. Program function: find the cubic sum of all integers between 1 and 130 and output the result. There are errors in two lines of the program.

29. Program function: find the sum of all primes in [3500]. (first, how to find prime numbers)

30. Program function: change a one dollar bill into one cent, two cent and five cent coins, at least 8 each, and calculate the number of schemes.

31. Program function: let the sum of a four digit thousand digit number and a ten digit number be equal to the product of a hundred digit number and a single digit number. For example, for four digits: 9512, 9 + 1 = 5 * 2, find the sum of all such four digits.

32. Program function: if a four digit positive integer is the square of another positive integer and the sum of each digit is a square number, the four digit positive integer is called "four digit double square number". For example, since 7396 = 86 ^ 2 and 7 + 3 + 9 + 6 = 25 = 5 ^ 2, 7396 is called "four digit double square number". Find the smallest "four digit double square number".

33. Program function: calculate y = 1 + 2 / 3 + 3 / 5 + 4 / 7 +... + n / (2 * n-1) (n = 50). Requirements: accurate to the second decimal place by rounding.

34. Program function: when n = 20, 1 / (1 * 2) + 1 / (2 * 3) + 1 / (3 * 4) ++ 1 / (n * (n + 1)). Requirement: it shall be rounded to the second decimal place.

35. Program function: palindrome number refers to the positive integer with the same positive reading and reverse reading. For example, 3773 is the palindrome number. Find the number of odd palindromes between [10009999].

36. Program function: find the value of expression t = 1-1 / (2 * 2) - 1 / (3 * 3) -... - 1 / (m * m) when m = 50. Requirement: it shall be rounded to the fourth digit after the decimal point.

37. Program function: find the number of all integers between [101000] that meet the requirements of dividing 7 by 5, dividing 5 by 3, and dividing 3 by 1.

38. Program function: hundreds of money and hundreds of chickens. With 100 money to buy 100 chickens, five for a rooster, three for a hen and three for a chick, there are several buying methods for programming calculation (it is required to buy at least one chicken of each kind).

39. Program function: find out how many groups of I, J and K conform to the formula ijk + kji = 1333, where I, J and K are one digit integers between 0 and 9.

40. Program function: find the sum of all digits in the four digit odd number is the sum of multiples of 25.

41. Program function: according to the value of integer parameter m, calculate the value of formula t = 1-1 / (2 * 2) - 1 / (3 * 3) -... - 1 / (m * m) (M = 100).

42. Program function: calculate the sum of the reciprocal of the square root of 1-123 according to the integer parameter M.

43. Program function: use the formula pi / 4 = 1-1 / 3 + 1 / 5-1 / 7 +... To find the approximate value of PI (PI is the PI), until the absolute value of the last item is less than the specified number (parameter Num).

44. Program function: according to the following formula pi / 2 = 1 + 1 / 3 + 1 / 3 * 2 / 5 + 1 / 3 * 2 / 5 * 3 / 7 + 1 / 3 * 2 / 5 * 3 / 7 * 4 / 9 +... Calculate the value of PI (PI is the PI). Stop the calculation when the value of the last item is less than 0.0005.

45. Program function: calculate the least common multiple of two numbers

46. Program function: find the sum of all leap year numbers from 1900 to 2003. (a leap year is a year that can be divided by 400, or a leap year that can be divided by 4 but cannot be divided by 100)

47. Program function: calculate the maximum common divisor of two numbers.

48. Program function: a number appears on the right of the square of the number, which is called "isomorphic number". For example, if 5 appears to the right of square number 25 and 25 appears to the right of square number 625, then 5 and 25 are "isomorphic numbers". Find the number of all "isomorphic numbers" between [11000].

49. Program function: find the sum of ASCII codes of all characters of the string "this is my basic".

50. Program function: find the number of groups (a, B, c) that meet the following conditions: (1) 1 / (a ^ 2) + 1 / (b ^ 2) = 1 / (C ^ 2); (2)a>b>c ;(3)a+b+c<100。

51. Program function: find the sum of all four digits whose single digit is 6 and can be divided by 3.

52. Program function: there is a pile of parts (the number of parts does not exceed 1000). If it is divided into 4 parts, there are 2 parts in a group; 7 parts in a group, there are 3 parts; 9 parts in a group, there are 5 parts. There are several possibilities to calculate the number of parts in this pile.

53. Program function: find such a three digit number, and its single digit number shall not be greater than 2. If the single digit is moved to before the hundred digit (for example, 321 is moved to 132), the new three digit is greater than twice the original three digit.

54. Program function: there is a pile of peaches (no more than 1000). If they are divided into 4 groups, there are 2 peaches; 7 groups, there are 3 peaches; 9 groups, there are 5 peaches. There are several possibilities to find the number of peaches in this pile.

55. Program function: sum = D + DD + DDD +... + DDD D (D is a number from 1 to 9). For example, 3 + 33 + 333 + 3333 (at this time, d = 3, n = 4) input the value of D from the keyboard as 3 and the value of n as 4.

56. Program function: find the sum of the first several items of sequence 2, 16, 32. When the sum is greater than 9000, the summation is terminated and the result is output.

57. Program function: the number of methods to convert 50 yuan into 5 yuan, 2 yuan and 1 yuan (each denomination cannot be 0).

58. Program function: a test paper is composed of 26 questions. 8 points will be given if one question is answered correctly, and 5 points will be deducted if one question is answered incorrectly. Today, a candidate answered all 26 questions, but the total score was zero. Ask him how many questions he answered wrong.

59. Program function: there are several students in a class, numbered 1, 2, 3,... In turn. Except for the two students numbered 1 and 2, the sum of all student numbers is an integral multiple of 100. If you know that the sum of student numbers is less than 1000, ask how many students there are in total.

60. Program function: in a positive integer sequence, the first term is 1978 and the second term is 1979. From the third term, each term is equal to the absolute value of the difference between the first two terms. Ask how many terms there are in this series.

61. Program function: there is a pile of parts (the number of parts does not exceed 1000). If it is divided into 4 parts, there are 2 parts in a group; 7 parts in a group, there are 3 parts; 9 parts in a group, there are 5 parts. There are several possibilities to calculate the number of parts in this pile.

62. Program function: find the number of groups of Pythagorean numbers between 1 and 200 (if a * a + b * b = C * C, then a, B and C are a group of Pythagorean numbers).

63. Program function: given an integer matrix of 100 rows and 100 columns, find the sum of the elements on the diagonal from the upper left to the lower right. (what do you know first)

64. For a car traveling at a fixed speed, the driver sees that the reading from left to right on the odometer is the same as that from right to left. This number is 12321 (km). Two hours later, a new symmetrical number appears on the odometer again. What is the speed of the car? Km / h?

65. N individuals form a circle (numbered 1-N). Start from the person No. 1 and count from 1. Those who report multiple of 3 leave the circle, and then count until there is only one person left. When n = 17, what are the numbers of the remaining people?

66. Find the number of prime numbers in the first 100 items of the sequence f (n) = n * n + N + 41

67. During the drill, when the soldiers change into 10, 21, 35 and 60 rows, the formation can be rectangular. How many soldiers will participate in the drill at least?

68. Count age. Add 6 times to the sum of Grandpa's age, multiply by 20, add grandma's age, subtract 365, and the number is 6924. It is also known that grandpa is 2 years older than grandma. Ask for the sum of Grandpa's and grandma's ages.

69. There were 1225 handshakes at the banquet. It was assumed that everyone attending the banquet had the same etiquette to other participants. How many participants were there?

70. Venus and the earth are at a certain position relative to the sun at a certain time. It is known that Venus orbits the sun for 225 days and the earth orbits the sun for 365 days. How many days does it take for the two planets to return to their original position at the same time?

71. Find the expression e ^ x ≈ 1 + X + x ^ 2 / 2+ x^3/3!+ x^4/4!……+ x^n/n! Let x = 9, n = 25;

72. Find the expression e ^ x ≈ 1 + X + x ^ 2 / 2+ x^3/3!+ x^4/4!……+ x^n/n! Until the last term is less than 0.01; Let x = 9

73. Use sin (x) ≈ x-x ^ 3 / 3+ x^5/5!-……+ (-1)^(n-1)*(x^(2n-1))/(2n-1)! Approximate the formula. Let x = 7, n = 15.

74. Use sin (x) ≈ x-x ^ 3 / 3+ x^5/5!-……+ (-1)^(n-1)*(x^(2n-1))/(2n-1)! Approximate the formula until the absolute value of the last term is less than 0.00001. Let x = 7.

75. Use cos (x) ≈ 1-x ^ 2 / 2+ x^4/4!-……+ (-1)^(n)*(x^(2n))/(2n)! Let x = 9 and N = 15

76. Use cos (x) ≈ 1-x ^ 2 / 2+ x^4/4!-……+ (-1)^(n)*(x^(2n))/(2n)! Approximate the formula until the absolute value of the last term is less than 0.00001. Let x = 7.

77. Known Sn = a1 + A2 + a3 ++ An, when n is odd, an = n-1; when n is even, an = n + 1 For example: S6 = 0 + 3 + 2 + 5 + 4 + 7, find: S60 = a1 + A2 + a3 ++ A60.

78. Ask in 1, In 100, select two different numbers and require their sum to be the logarithm of the number divisible by 3 and 7 (Note: 3 + 5 and 5 + 3 are considered to be the same logarithm).

79. It is known that S1 = 1, S2 = 1 + 2, S3 = 1 + 2 + 3, Sn = 1 + 2 + 3 ++ N. Find the sum of all numbers divisible by 3 and 7 in S1, S2, S3 and S100

80. It is known that in the Fibonacci sequence {x}, X (1) = 0, X (2) = 1, X (n) = x (n-1) + X (n-2), program to calculate the sum of all prime numbers in the first 30 numbers of the sequence.

81. Among the three digits, the remainder obtained by dividing the sum of individual digits and ten digits by 10 is a hundred digit number, and the hundred digit number is the number of even numbers.

82. A prime number is called super prime number. If the prime number removes one bit, ten bits Wait, the number obtained each time is still prime. For example, 239 is a super prime. Find the number of super primes in [1009999]

83. Find the number of rows 20 and columns 10 in Yang Hui triangle? Yang Hui triangle: 1 1 1 1 2 1 3 1 4 6 4 1.................................. (check what is Yang Hui triangle by yourself)

84. If a number is just equal to the sum of all its factors, it is called "perfect". For example, 6 = 1 + 2 + 3, then 6 is a perfect. Program to find the number of completions between [80009000].

85. Chinese ancient mathematicians wrote a question in the Suanjing: Chicken Weng Yi is worth five; A hen is worth three; Three chicks are worth one. When you buy a hundred chickens for a hundred dollars, ask the chicken owner, the mother and the chick. " It means that one rooster is worth 5 yuan, one hen is worth 3 yuan, and three chicks are worth 1 yuan. Programming to buy 100 chickens with 100 hanging money. There are at least one rooster, hen and chick of each kind. How many ways to buy?

86. The first few numbers of Fibonacci sequence are: 0, 1, 1, 2, 3, 5,... The law is: F1 = 0 (n = 1) F2 = 1 (n = 2) FN = fn-1 + fn-2 (n ≥ 3) program to calculate the sum of the first 40 items of this sequence.

87. Catching traffic offenders: a truck violated traffic rules and ran away after hitting people. Three people witnessed the incident, but they didn't remember the car number, only some characteristics of the car number. A said: the first two digits of the licence are the same; B: the last two digits of the licence are the same, but different from the first two digits; C said: the four digit car number is just the square of an integer.

88.4-bit inverse ordinal number: let n be a four digit number, and its 9 times is exactly its inverse ordinal number, find n. (the inverse number is an integer formed by reversing the number of integers. For example, the inverse number of 1234 is 4321.)

89. The problem of mantissa of higher-order equation: what are the last three digits of the 298th power of 13? Programming.

90. Input two numbers 51211314 and 84131421 from the keyboard, and use the rolling division method to find their maximum common divisor. Ask how many times you need to go through.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>