-
面向?qū)ο缶幊痰母拍?/p>
面向?qū)ο笕筇卣?/p>
阿里云API市場接入
查看全部 -
//判斷一個(gè)素?cái)?shù)能被幾個(gè)9整除.
/*import java.util.Scanner;
public class Test {
? ?public static void main(String[] args) {
? ? ? ?System.out.print("請(qǐng)輸入一個(gè)數(shù):");
? ? ? ?Scanner scan = new Scanner(System.in);
? ? ? long l=scan.nextLong();
? ? ? ? ? long n=l;
? ? ? ? ? scan.close();
? ? ? ? ? int a=0;
? ? ? ? ? while(n>8) {
? ? ? ? ? ? ? n /= 9;
? ? ? ? ? ? ? a++;
? ? ? ? ? }
? ? ? ? ? ? ? System.out.println(l+"能被"+n+"整除");
? ? ? ? ? }\
? ? ? ?}*/
import java.util.Arrays;
public class Test {
? ?public static void main(String[] args) {
? ? ? ?int[] a = {4, 5, 9, 7};
? ? ? ?int[] b = new int[a.length];
? ? ? ?int j = a.length;
? ? ? ?for (int i= 0; i < a.length; i++) {
? ? ? ? ? ?b[i] = a[j - 1];
j--;
? ? ? ? ? ?System.out.println(Arrays.toString(b));
? ? ? ?}
? ?}
}
/*
public class Test {
? ?public static void main(String[] args) {
? ? ? ?int[][] arr = new int[6][6];
? ? ? ?for (int i = 0; i < arr.length; i++) {
? ? ? ? ? ?arr[i][0] = 1;//控制第一列的數(shù)等于1
? ? ? ?}
? ? ? ?for (int i = 1; i < arr.length; i++) {
? ? ? ? ? ?for (int j = 1; j < arr.length; j++) {
? ? ? ? ? ? ? ?arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];//賦值
? ? ? ? ? ?}
? ? ? ?}
? ? ? ?//打印結(jié)果
? ? ? ?for (int i = 0; i < arr.length; i++) {
? ? ? ? ? ?for (int k = arr.length - i; k > 0; k--) {//空格的控制,為了好看
? ? ? ? ? ? ? ?System.out.print(" ?");
? ? ? ? ? ?}
? ? ? ? ? ?for (int j = 0; j < arr.length; j++) {//打印出數(shù)組的數(shù)字
? ? ? ? ? ? ? ?if (arr[i][j] != 0) {//把沒賦值的零去掉
? ? ? ? ? ? ? ? ? ?System.out.print(arr[i][j] + " ? ");
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ? ? ?System.out.println();//控制換行
? ? ? ?}
? ?}
public class Test {
? ?public static boolean isTest(int a){
? ? ? ?int cup = 0;
? ? ? ?for(int i=1; i<a; i++){
? ? ? ? ? ?if(a%i == 0)
? ? ? ? ? ? ? ?cup = cup + i;
? ? ? ?}
? ? ? ?return (cup == a);
? ?}
? ?public static void main(String[] args) {
? ? ? ?for(int i=1; i<1000; i++){
? ? ? ? ? ?if(isTest(i)){
? ? ? ? ? ? ? ?System.out.print(i + ",");
? ? ? ? ? ?}
? ? ? ?}
? ?}}*//*某個(gè)公司采用公用電話傳遞數(shù)據(jù),數(shù)據(jù)是四位的整數(shù),在傳遞過程中是加密的,加密規(guī)則如下:每位數(shù)字
? ? ? ?都加上5,然后用和除以10的余數(shù)代替該數(shù)字,再將第一位和第四位交換,第二位和第三位交換。
public class Xeon {
? ?public static void main(String[] args) {
? ? ? ?int i=1632;
? ? ? ?int a=i/100+5;
? ? ? ?int b=i%100/10+5;
? ? ? ?int c=i%10+5;
? ? ? ?int d=i/1000+5;
? ? ? ?double h=a+b+c+d;
? ? ? ?double p=h/10;
? ? ? ?System.out.println(d);
? ? ? ?System.out.println(p);
int[]f={a,b,c,d};
if(f[0]>f[3]){
? ?f[0]=f[3];
}
if(f[1]>f[2]){
? ?f[1]=f[2];
? ?}
System.out.println(f[0]);
? ?}}*/查看全部 -
接口(interface)是一個(gè)抽象的類型,只提供方法的定義查看全部
-
a
查看全部 -
a
查看全部 -
q
查看全部 -
1
查看全部 -
1
查看全部 -
1
查看全部 -
1
查看全部 -
1
查看全部 -
1
查看全部 -
包的命名規(guī)范
查看全部 -
?
public class 類名{
? public 輸出數(shù)據(jù)類型 方法名 (輸入數(shù)據(jù)類型 變量名){方法內(nèi)容}
? public static void main(String[] args){
? ? ? ? ? ? ? ? ? ? 調(diào)用方法
? }
}
調(diào)用方法:方法只能作用于對(duì)象 所以首先對(duì)象實(shí)例化
? ? ? ? ? ? ? ? ?創(chuàng)建變量接收輸出結(jié)果? ? ?輸出數(shù)據(jù)類型 變量名=對(duì)象名.方法名 (輸入數(shù)據(jù))
查看全部 -
使用范例
查看全部
舉報(bào)