導航:首頁 > 編程語言 > java顯示字元的平方排布

java顯示字元的平方排布

發布時間:2021-03-29 20:20:44

java 中,怎麼列印出一個字元串的所有排列

import java.util.Scanner;

public class Test {
public static void main(String[] args) {
String str = "";

Scanner scan = new Scanner(System.in);

str = scan.nextLine();

permutation(str.toCharArray(), 0);
}

public static void permutation(char[] str, int i) {
if (i >= str.length)
return;
if (i == str.length - 1) {
System.out.println(String.valueOf(str));
} else {
for (int j = i; j < str.length; j++) {
char temp = str[j];
str[j] = str[i];
str[i] = temp;

permutation(str, i + 1);

temp = str[j];
str[j] = str[i];
str[i] = temp;
}
}
}
}

❷ 用java編寫程序顯示字元編排圖案

publicclassTest2014112005{
publicstaticvoidmain(Stringargs[]){
String[][]strs=newString[][]{
{"","","","J","","","","","A","","","","V","","","","","","V","","","","","A","","",""},
{"","","","J","","","","A","","A","","","","V","","","","V","","","","","A","","A","",""},
{"J","","","J","","","A","A","A","A","A","","","","V","","V","","","","","A","A","A","A","A",""},
{"","J","J","","","A","","","","","","A","","","","V","","","","","A","","","","","","A"},};
for(inti=0;i<strs.length;i++){
for(intj=0;j<strs[i].length;j++){
System.out.print(strs[i][j]);
}
System.out.println();
}
}
}

這?

❸ 在java中數字的平方怎樣表示

在Java中,求一個數平方,可以:

tmp = n*n;

Math.pow(n,2)

拓展資料:平方是一種運算,比如,a的平方表示a×a,簡寫成a²,也可寫成a×a(a的一次方乘a的一次方等於a的2次方),例如4×4=16,8×8=64,平方符號為2。

❹ java中如何顯示字元串位置

java中輸出字元所在位置可以使用indexOf()函數
例子:
System.out.println("abcd".indexOf("b"));
結果輸出1
返回b字元在字元串abcd中第一次出現的位置

❺ java的平方表達式怎麼寫

「java」的平方表達式是pow (double x,double y)。

函數原型:double pow (double x,double y)。

功能:返回x的y次方。

如要在java中求9的平方,可寫作double pow(double 9,double 9)。

❻ java 輸入一個字元串,列印出該字元串中字元的所有排列

實現思路:就是輸入字元串後,通過遞歸的方式,循環每個位置和其他位置的字元。

importjava.util.Scanner;

publicclassDemo001{

publicstaticvoidmain(String[]args){
Stringstr="";

Scannerscan=newScanner(System.in);

str=scan.nextLine();

permutation(str.toCharArray(),0);
}

publicstaticvoidpermutation(char[]str,inti){
if(i>=str.length)
return;
if(i==str.length-1){
System.out.println(String.valueOf(str));
}else{
for(intj=i;j<str.length;j++){
chartemp=str[j];
str[j]=str[i];
str[i]=temp;

permutation(str,i+1);

temp=str[j];
str[j]=str[i];
str[i]=temp;
}
}
}
}

❼ java中怎麼給一個字元串弄平方呢比如要把讓x這個字元串帶上平方,用Math.pow(double,double).

public static double pow(double a,double b) 官方文檔就是這么定義的,你可以先把String類型轉為double類型,再進行平方啊

閱讀全文

與java顯示字元的平方排布相關的資料

熱點內容
拍照破解手機圖案密碼 瀏覽:885
安卓shell查看進程 瀏覽:158
mysql資料庫longtext 瀏覽:568
嵌入式linux有哪些特點 瀏覽:587
展開收縮代碼 瀏覽:189
archlinuxfn 瀏覽:744
文件檔案管理系統畢業設計 瀏覽:391
網路機頂盒電視沒信號怎麼回事 瀏覽:384
蘋果手機如何下載來玩 瀏覽:826
win10安裝重新啟動 瀏覽:395
復制文件和文件夾出錯 瀏覽:652
加工中心編程如何學 瀏覽:16
電腦掃碼支付密碼嗎 瀏覽:815
網路微信平台 瀏覽:165
applepay未添加此卡 瀏覽:201
哪個網站可以試玩cq9游戲 瀏覽:367
怎麼查電信光纖賬號和密碼是什麼樣的 瀏覽:830
iphone如何發錄音文件 瀏覽:982
windowsxp桌面小工具 瀏覽:154
運動類app開發設計 瀏覽:401

友情鏈接