返回列表 發帖
105
  1. import java.util.Scanner;
  2. public class JP108 {
  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.         Scanner s=new Scanner(System.in);
  6.         int d=s.nextInt();
  7.         double=d/2.0;
  8.         double area=r*r*3.1415;
  9.         System.out.printf("%-10\n%-10.2f\n%-10.4f",d,r,area);
  10.         }

  11. }
複製代碼
108
  1. package zcor;
  2. import java.util.Scanner;
  3. public class JP108 {
  4.         public static void main(String[] args) {
  5.                 Scanner s=new Scanner(System.in);
  6.                 int d=s.nextInt();
  7.                 double r=d/2.0;
  8.                 double area=r*r*3.1415;
  9.                 System.out.printf("%-10d \n %-10.2f \n %-10.4f",d,r,area);
  10.         }

  11. }
複製代碼
207
  1. import java.util.Scanner;
  2. public class JP206 {
  3.         public static void main(String[] args) {
  4.                 Scanner s=new Scanner(System.in);
  5.                 int n=s.nextInt();
  6.                 for(int i=2;i<n;i++){
  7.                         if(n%i==0){
  8.                                 System.out.println(n+" is not a prime number");
  9.                                 return;
  10.                         }
  11.                 }
  12.                 System.out.println(n+"is a prime number");
  13.         }
  14. }
複製代碼
310
  1. import java.util.Scanner;
  2. public class JP310 {
  3.     static int compute(int n)
  4.     {
  5.         int total=0;
  6.         for(int i=1; i<n; i++)
  7.         {
  8.             int sum=0;
  9.             String str=String.valueOf(i);// int to string
  10.             int len=str.length();//length() 得到字串長度
  11.             for(int j=0; j<len; j++)
  12.             {
  13.                 int t=str.charAt(j)-'0';//將各個數字轉換為int
  14.                 sum+=Math.pow(t, len);//並進行自身位數次方的動作
  15.             }
  16.             if(sum==i)//判斷是否為阿姆斯壯數
  17.             {
  18.                 System.out.println(i);
  19.                 total+=i;
  20.             }
  21.         }
  22.         return total;
  23.     }
  24.     public static void main(String[] args) {
  25.         Scanner s=new Scanner(System.in);
  26.         int n=s.nextInt();
  27.         System.out.println(compute(n));
複製代碼
404
  1. import java.util.Scanner;
  2. public class JP404 {
  3.     public static void main(String[] args) {
  4.         Scanner s=new Scanner(System.in);
  5.         String str=s.nextLine();
  6.         int len=str.length();
  7.         int sum[]=new int['z'+1];
  8.         int maxV=Integer.MIN_VALUE;
  9.         char c=0;
  10.         for(int i=0; i<len; i++)
  11.             sum[str.charAt(i)]++;
  12.         for(int i='a'; i<='z'; i++)
  13.         {
  14.             if(sum[i]>maxV)
  15.             {
  16.                 maxV=sum[i];
  17.                 c=(char)i;
  18.             }
  19.         }
  20.         System.out.println(c);
  21.         System.out.println(maxV);
  22.     }
  23. }
複製代碼

TOP

返回列表