Baiqian White Chicken problem
1 PackageCom.lovo;2 3 Public classtest12 {4 Public Static voidMain (string[] args) {5 for(inti = 0; I <= 20; i++) {6 for(intj = 0; J <= 33; J + +) {7 for(intk = 0; K <= 100; k++) {8 if((5 * i + 3 * j + K/3 = +) && (i + j + k = =) &&k%3==0) {9System.out.printf ("Rooster%d only \ n hen%d \ n chick%d only \ n"), I, J, K);Ten } One } A } - } - } the -}
1 to 100 inside prime
Package Com.lovo;public class Test14 {public static void main (string[] args) {System.out.println ("1 to 100 primes:"); for (int i =2;i<=100;i++) {int sum=0;for (int j=1;j<=i;j++) {if (i%j==0) {sum++;}} if (sum==2) {System.out.print (i+ " ");}}}
Two numbers of greatest common divisor and least common multiple
Package Com.lovo;import Java.util.scanner;public class test13 {public static void main (string[] args) {int s=0; Scanner sc=new Scanner (system.in); System.out.println ("n="); int n=sc.nextint (); System.out.println ("m="), int m=sc.nextint (), for (int i=math.min (m, N), i>=1;i--) {if ((n%i==0) && (m%i==0)) { System.out.println (n+ "and" +m+ "greatest common divisor:" +i "; break;}} for (int J=math.max (n, m), j<=n*m;j++) {if ((j%n==0) && (j%m==0)) {System.out.println (n+ "and" +m+ "least common multiple are:" +j "); Break;}} Sc.close ();}}
Java Programs (1016)