herrDeng網內搜尋

自訂搜尋

Ads

2015年12月11日 星期五

程式設計練習2

String X=" What  test is that? this is a....."
1.去掉空格
2. 取子字串4~21
3. this->這, is->是, a->一個, test->嘗試
4. 改大寫
5. 字串反轉
6. 將字串2,4,6,8,10,.....的字元組成一新字串

28 則留言:

A10433038 提到...

import java.security.SecureRandom;

public class jimmy12 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數"+count[j]); } }}




a10433013 提到...

import javax.xml.crypto.dsig.spec.XSLTTransformParameterSpec;public class abcd {public static void main(String[] args) { String x=" What test is that? this is a....."; System.out.println(x); x=x.replace(" ",""); System.out.println(x); x=x.substring(4,22); System.out.println(x); x=x.replace("this","這"); x=x.replace("is","是"); x=x.replace("a","一個"); x=x.replace("test","嘗試"); System.out.println(x); x=x.toUpperCase(); System.out.println(x); String a=""; for(int i=x.length()-1;i>0;i--) a+=x.charAt(i); x=a; System.out.print(a); String y=""; for(int j=2;j<a.length()-1;j+=2) y+=a.charAt(j); System.out.println(); System.out.print(y);}}

A10433006 提到...

public class X1211 {

public static void main(String[] args) { String X="What test is that?this is a...."; X=X.replace(" ",""); System.out.println(X); X=X.substring(4,22); System.out.println(X); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String X1=new String(new StringBuffer(X).reverse()); String tmp=""; for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); } }

a10433029 提到...



public class ccc29 {

public static void main(String[] args) { String X=" What test is that? this is a....."; X=X.replace(" ", ""); System.out.println(X); System.out.println(X=X.substring(4,22)); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String tmp=""; for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); } }


A10433008 提到...



public class ex11 {

public static void main(String[] args) { String X="what test is that? this is a...."; X=X.replace(" ",""); System.out.println(X); X=X.replace("this","這"); X=X.replace("tis","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String X1=new String(new StringBuffer(X).reverse()); String tmp=""; for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2);

}

}

a10433019 提到...



public class ccc29 {

public static void main(String[] args) { String X=" What test is that? this is a....."; X=X.replace(" ", ""); System.out.println(X); System.out.println(X=X.substring(4,22)); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String tmp=""; for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); } }


A10433004 提到...

public class ex2 {
public static void main(String[] args) {
String X=" What test is that? this is a.....";
X=X.replace(" ", "");
System.out.println(X);
X=X.substring(4,22);
System.out.println(X);
X=X.replace("this", "這");
X=X.replace("is", "是");
X=X.replace("a", "一個");
X=X.replace("test", "嘗試");
System.out.println(X);
X=X.toUpperCase();
System.out.println(X);

String tmp="";
for(int i=X.length()-1;i>=0;i--)
tmp+=X.charAt(i);
X=tmp;
System.out.println(X);

String X2="";
for(int i=2;i<X.length();i+=2){
X2+=X.charAt(i);
}
System.out.println(X2);
}}

A10433011 提到...

package zz;

public class z2 {

public static void main(String[] args) { String X=" What test is that? this is a....."; X=X.replace(" ",""); X=X.substring(4,22); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); X=X.toUpperCase(); System.out.println(X); String x1 = new String(new StringBuffer(X).reverse()); String tmp=""; for(int i =X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); } }


A10433018 提到...

package rpg; public class FHM { public static void main(String[] args) { String x=" What test is that? this is a....."; x=x.replace(" ",""); x=x.substring(4,22); x=x.replace("this","這"); x=x.replace("is","是"); x=x.replace("a","一個"); x=x.replace("test","嘗試"); x=x.toUpperCase();String a; char y[]=x.toCharArray(); String x1=new String(new StringBuffer(x).reverse()); String d=""; for(int i=x.length()-1;i>=0;i--) d+=x.charAt(i); x=d; System.out.println(x); String x2=""; for(int i=2;i

A10433024 提到...

package rpg; public class FHM { public static void main(String[] args) { String x=" What test is that? this is a....."; x=x.replace(" ",""); x=x.substring(4,22); x=x.replace("this","這"); x=x.replace("is","是"); x=x.replace("a","一個"); x=x.replace("test","嘗試"); x=x.toUpperCase();String a; char y[]=x.toCharArray(); String x1=new String(new StringBuffer(x).reverse()); String d=""; for(int i=x.length()-1;i>=0;i--) d+=x.charAt(i); x=d; System.out.println(x); String x2=""; for(int i=2;i

A10433007 提到...

public class ex3 {

public static void main(String[] args) { String X="What test is that?this is a...."; X=X.replace("",""); System.out.println(X); X=X.substring(4, 22); System.out.println(X); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String X1=new String(new StringBuffer(X).reverse());//StringBuffer// System.out.println(X1);// String tmp=""; //for loop法 for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); }

}

A10433010 提到...

public class ex3 {

public static void main(String[] args) { String X="What test is that?this is a...."; X=X.replace("",""); System.out.println(X); X=X.substring(4, 22); System.out.println(X); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String X1=new String(new StringBuffer(X).reverse());//StringBuffer// System.out.println(X1);// String tmp=""; //for loop法 for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); }

}

A10433014 提到...

public class ex3 {

public static void main(String[] args) { String X="What test is that?this is a...."; X=X.replace("",""); System.out.println(X); X=X.substring(4, 22); System.out.println(X); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String X1=new String(new StringBuffer(X).reverse());//StringBuffer// System.out.println(X1);// String tmp=""; //for loop法 for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); }

}

A10433003 提到...

public class ex3 {

public static void main(String[] args) { String X="What test is that?this is a...."; X=X.replace("",""); System.out.println(X); X=X.substring(4, 22); System.out.println(X); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String X1=new String(new StringBuffer(X).reverse());//StringBuffer// System.out.println(X1);// String tmp=""; //for loop法 for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); }

}

A10433003 提到...

package hello;

import java.security.SecureRandom;

public class ex2 {

public static void main(String[] args) { SecureRandom rnd=new SecureRandom(); int[]a=new int[100]; int[]count=new int[10]; int y; for(int i=0;i<a.length;i++){ y=a[i]=rnd.nextInt(10); System.out.print(y+",\t"); if(i%10==9)System.out.println(); count[y]++; } System.out.println(); for(int j=0;j<count.length;j++){ System.out.println(j+"出現次數:"+count[j]); } }

}

A10433036 提到...



public class a02 {

public static void main(String[] args) { String X="What test is that? this is a ...."; X=X.replace("",""); System.out.println(X); X=X.substring(4,22); System.out.println(X); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String X1=new String(new StringBuffer(X).reverse());//StringBuffer //System.out,println(X1); // String tmp="";//for loop法 for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ } System.out.println(X2); }

}

A10433038 提到...

public class JIM12 {

public static void main(String[] args) { String X="What testis that?this is a..."; X=X replace("",""); System.out.println(X); X=X substring(4,22); System.out.println(x); X=X replace("this","這"); X=X replace("is","是"); X=X replace("a","一個"); X=X replace("test","嘗試") System.out.println(X); X=X toUpperCase(); System.out.println(X); String X1=new String(new string buffer(X).reverse();//stringBuffer// System.out.println(X1);// String tmp""//for loop法 }

}

A10433007 提到...

public class ex4 { static int[]SmallPrime={2,3,5,7};//Math.sqrt(120)=10.xx static boolean isPrime(int N){ for(int i=0;i<SmallPrime.length;i++) if(N==SmallPrime[i]) return true; else if(N%SmallPrime[i]==0) return false; return true; } public static void main(String[] args) { int count=0; for(int i=3; i<=120; i++) { if(isPrime(i)&&isPrime(i+2)) System.out.println((++count)+":("+i+","+(i+2)+")");

}

}

}

A10433010 提到...

public class ex4 { static int[]SmallPrime={2,3,5,7};//Math.sqrt(120)=10.xx static boolean isPrime(int N){ for(int i=0;i<SmallPrime.length;i++) if(N==SmallPrime[i]) return true; else if(N%SmallPrime[i]==0) return false; return true; } public static void main(String[] args) { int count=0; for(int i=3; i<=120; i++) { if(isPrime(i)&&isPrime(i+2)) System.out.println((++count)+":("+i+","+(i+2)+")");

}

}

}

A10433014 提到...

public class ex4 { static int[]SmallPrime={2,3,5,7};//Math.sqrt(120)=10.xx static boolean isPrime(int N){ for(int i=0;i<SmallPrime.length;i++) if(N==SmallPrime[i]) return true; else if(N%SmallPrime[i]==0) return false; return true; } public static void main(String[] args) { int count=0; for(int i=3; i<=120; i++) { if(isPrime(i)&&isPrime(i+2)) System.out.println((++count)+":("+i+","+(i+2)+")");

}

}

}

A10433003 提到...

public class ex4 { static int[]SmallPrime={2,3,5,7};//Math.sqrt(120)=10.xx static boolean isPrime(int N){ for(int i=0;i<SmallPrime.length;i++) if(N==SmallPrime[i]) return true; else if(N%SmallPrime[i]==0) return false; return true; } public static void main(String[] args) { int count=0; for(int i=3; i<=120; i++) { if(isPrime(i)&&isPrime(i+2)) System.out.println((++count)+":("+i+","+(i+2)+")");

}

}

}

A10433028 提到...

public class ex2 { public static void main(String[] args) { String x="What test is that? this is a....."; System.out.println(x=x.replace(" ","")); System.out.println(x.substring(4,22)); x=x.substring(4,22); x=x.replace("this","這"); x=x.replace("a","一個"); x=x.replace("test","嘗試"); x=x.replace("is","是"); System.out.println(x); System.out.println(x.toUpperCase()); x=x.toUpperCase(); String X1=new String(new StringBuffer(x).reverse()); String tmp=""; for(int i=x.length()-1;i>=0;i--) tmp+=x.charAt(i); x=tmp; System.out.println(x); String X2=""; for(int i=2;i<x.length();i+=2){ X2+=x.charAt(i); } System.out.println(X2); }}

A10433015 提到...



public class cccc {

public static void main(String[] args) { String x=" What test is that? this is a....."; x=x.replace(" ", ""); System.out.println(x); x=x.substring(4, 22); System.out.println(x); x=x.replace("this","這" ); x=x.replace("is","是" ); x=x.replace("a","一個" ); x=x.replace("test","嘗試" ); System.out.println(x); x=x.toUpperCase(); System.out.println(x); String z=""; for (int i=x.length()-1;i>=0;i--) z+=x.charAt(i); x=z; System.out.print(x); String zx=""; for(int c=2;c<x.length();c+=2) zx+=x.charAt(c); x=zx; }}

A10433001 提到...

public class cccc {

public static void main(String[] args) { String x=" What test is that? this is a....."; x=x.replace(" ", ""); System.out.println(x); x=x.substring(4, 22); System.out.println(x); x=x.replace("this","這" ); x=x.replace("is","是" ); x=x.replace("a","一個" ); x=x.replace("test","嘗試" ); System.out.println(x); x=x.toUpperCase(); System.out.println(x); String z=""; for (int i=x.length()-1;i>=0;i--) z+=x.charAt(i); x=z; System.out.print(x); String zx=""; for(int c=2;c<x.length();c+=2) zx+=x.charAt(c); x=zx; }}

10433020 提到...

public static void main(String[] args) { String X=" What test is that? this is a....."; X=X.replace(" ",""); X=X.substring(4,22); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); X=X.toUpperCase(); System.out.println(X); String x1 = new String(new StringBuffer(X).reverse()); String tmp=""; for(int i =X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); } }

A10433043 提到...

public class ex3 {

public static void main(String[] args) { String X="What test is that?this is a...."; X=X.replace("",""); System.out.println(X); X=X.substring(4, 22); System.out.println(X); X=X.replace("this","這"); X=X.replace("is","是"); X=X.replace("a","一個"); X=X.replace("test","嘗試"); System.out.println(X); X=X.toUpperCase(); System.out.println(X); String X1=new String(new StringBuffer(X).reverse());//StringBuffer// System.out.println(X1);// String tmp=""; //for loop法 for(int i=X.length()-1;i>=0;i--) tmp+=X.charAt(i); X=tmp; System.out.println(X); String X2=""; for(int i=2;i<X.length();i+=2){ X2+=X.charAt(i); } System.out.println(X2); }

}

A10433022 遲 提到...

public class ex2 { public static void main(String[] args) { String x="What test is that? this is a....."; System.out.println(x=x.replace(" ","")); System.out.println(x.substring(4,22)); x=x.substring(4,22); x=x.replace("this","這"); x=x.replace("a","一個"); x=x.replace("test","嘗試"); x=x.replace("is","是"); System.out.println(x); System.out.println(x.toUpperCase()); x=x.toUpperCase(); String X1=new String(new StringBuffer(x).reverse()); String tmp=""; for(int i=x.length()-1;i>=0;i--) tmp+=x.charAt(i); x=tmp; System.out.println(x); String X2=""; for(int i=2;i<x.length();i+=2){ X2+=x.charAt(i); } System.out.println(X2); }}

B10133189 提到...

public class ex4 { static int[]SmallPrime={2,3,5,7};//Math.sqrt(120)=10.xx static boolean isPrime(int N){ for(int i=0;i<SmallPrime.length;i++) if(N==SmallPrime[i]) return true; else if(N%SmallPrime[i]==0) return false; return true; } public static void main(String[] args) { int count=0; for(int i=3; i<=120; i++) { if(isPrime(i)&&isPrime(i+2)) System.out.println((++count)+":("+i+","+(i+2)+")");

}

}

}

Related Posts Plugin for WordPress, Blogger...

熱門文章