返回列表 發帖
104
  1. import java.util.Scanner;
  2. public class JP104 {

  3.         public static void main(String[] args) {
  4.       
  5.                 Scanner sc=new Scanner(System.in);
  6.                 double n=sc.nextDouble();
  7.                 double x=sc.nextDouble();
  8.                
  9.                 double sum=n+x;

  10.      
  11.                 double avg=(double)sum/3;
  12.                 System.out.printf("total=%.2f",sum);

  13.         }
  14. }
複製代碼
108
  1. import java.util.Scanner;
  2. public class JP108 {

  3.         public static void main(String[] args) {
  4.                 Scanner sc=new Scanner(System.in);
  5.                 int d=sc.nextInt();
  6.                 double r=d/2.0;
  7.                 double x =r*r*3.1415;

  8.                 System.out.printf("%-10d\n%-10.2f\n%-10.4f",d,r,x);
  9.         }
  10. }
複製代碼
207
  1. import java.util.*;
  2. public class a001 {

  3.         public static void main(String[] args) {
  4.                 Scanner sc=new Scanner(System.in);
  5.                 int n=sc.nextInt();
  6.                 for(int i=2;i<n;i++)
  7.                 {
  8.                         if(n%i==0)
  9.                         {
  10.                                 System.out.println(n+" is not a prime number");
  11.                             return;
  12.                         }         
  13.                 }
  14.         System.out.println(n+" is a prime number");
  15.         }
  16. }
複製代碼
203
  1. import java.util.*;
  2. public class JP203 {

  3.         public static void main(String[] args) {

  4.                 Scanner sc=new Scanner(System.in);
  5.                 int n=sc.nextInt();

  6.                 if(n==1)
  7.                         System.out.println("one");
  8.                 else if(n==2)
  9.                         System.out.println("two");
  10.                 else if(n==3)      
  11.                         System.out.println("three");
  12.                 else if(n==4)      
  13.                         System.out.println("four");
  14.                 else
  15.                         System.out.println("error");
  16.         }

  17. }
複製代碼
310
  1. import java.util.Scanner;
  2. public class a001 {
  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);
  10.                         int len=str.length();
  11.                         for(int j=0; j<len; j++)
  12.                         {
  13.                                 int t=str.charAt(j)-'0';
  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));
  28.         }
  29. }
複製代碼

TOP

返回列表