返回列表 發帖
108
  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. }
複製代碼
105
  1. import java.util.Scanner;
  2. public class JP105 {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 Scanner sc= new Scanner(System.in);
  6.                 double a=sc.nextDouble();
  7.                 double b=sc.nextDouble();
  8.                
  9.                 System.out.printf("result%.2f.Math.sqrt(a+b)"(a+b));
  10.         }

  11. }
複製代碼
207
  1. import java.util.Scanner
  2. public class JP207 {

  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.             {
  8.                     if(n%i==0){
  9.                             System.out.println(n+"is a prime number");
  10.                             return;
  11.                     }
  12.             }
  13.             System.out.println(n+"is not a prime number");
  14.         }
  15. }
複製代碼
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.                     int sum=0;
  8.                     String str=String.valueOf(i);
  9.                     int len=str.length();
  10.                     for(int j=0;j<len;j++){
  11.                             int t=str.charAt(j)-'0';
  12.                             sum+=Math.pow(t,len);
  13.                     }
  14.                     if(sum==i){
  15.                             System.out.println(i);
  16.                             total+=i;
  17.                     }
  18.             }
  19.             return total;
  20.     }
  21.         public static void main(String[] args) {
  22.                
  23.                 Scanner sc=new Scanner(System.in) ;
  24.                 int n=sc.nextInt();
  25.                 System.out.println(compute(n));

  26.         }

  27. }
複製代碼
404
  1. import java.util.Scanner;


  2. public class JP404 {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 Scanner s=new Scanner(System.in);
  6.                
  7.                 int[] sum=new int[26];            
  8.                 int maxV=Integer.MIN_VALUE;        
  9.                 char ans='0';                              
  10.                
  11.                 String str;
  12.                 str=s.nextLine();
  13.                
  14.                
  15.                 for(int i=0;i<str.length();i++)
  16.                 {
  17.                         int c=str.charAt(i);
  18.                         sum[c-97]++;        
  19.                 }
  20.                
  21.                 for(int i=0;i<=25;i++)
  22.                 {
  23.                         if(sum[i]>maxV)
  24.                         {
  25.                                 maxV=sum[i];
  26.                                 ans=(char)(i+97);
  27.                         }
  28.                 }
  29.                 System.out.println(ans);
  30.                 System.out.println(maxV);
  31.         }
  32.       

  33. }
複製代碼

TOP

返回列表