2014年12月27日 星期六

java程式設計題目---數字處理【雙生質數(使用method)】

Twin primes(雙生質數) are a pair of prime numbers that differ by 2. For example, 3 and 5 are twin primes, 5 and 7 are twin primes, and 11 and 13 are twin primes. Write a program to find all twin primes less than 1,000. Display the output as follows:
(3,5)
(5,7)
...

java程式設計題目---公式計算【梅森質數(使用method)】

A prime number is called a Mersenne prime(梅森質數) if it can be written in the form 2^p-1 for some positive integer p.
Write a program that finds all Mersenne prime with p<=31 and displays the output as follows:
p     2^p-1
2         3
3         7
5         31
...

2014年12月26日 星期五

java程式設計題目---數字處理【迴文質數判斷(使用method)】

A palindromic prime is a prime number and also palindromic. For example, 131 is a prime and also a palindromic prime, as are 313 and 757. Write a program that displays the first 100 palindromic prime numbers. Display 10 numbers line, separated by exactly one space, as follows:
2 3 5 7 11 101 131 151 181 191
313 353 373 383 727 757  787 797 919 929

java程式設計題目---數字處理【迴文判斷(使用method)】

Write the methods with the following headers:
public static int reverse(int number)
public static Boolean isPalindrome(int number)
Use the reverse method to implement isPalindrome. A number is a palindrome if its reversal is the same as itself. Write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.

java程式設計題目---數字處理【數值反轉(使用method)】

Write a method with the following header to display an interger in reverse order:
public static int reverse(int number)
For example, reverse(3456) displays 6543. Write a test program that promotes the user to enter an integer and displays its reversal.

java程式設計題目---字母處理【輸出字母、換行(使用method)】

Write a method that prints characters using the following header:
public static void printChars(char ch1, char ch2, int numberPerLine)
This method prints the characters between ch1 and ch2 with the specified numbers per line. Write a test program the prints ten characters per line from 1 to Z. Character are separated by exactly one space.

java程式設計題目---圖形繪製【使用2的n次方印三角形(使用method)】

Write a method to display a pattern as follows:
1
1  2
1  2  4
1  2  4  8
      ...
1  2  4  8   ....
The method header is
public static void displayPattern(int n)

Go(Golang)程式語言 設定GCC

下載MSYS2:  https://www.msys2.org/ 安裝 程式開始執行後輸入: pacman -Syu y y 在安裝目錄底下找到msys2.exe,雙擊執行 輸入指令: pacman -Su pacman -S --needed base-devel mingw-...