本文主要是介绍School‘s Java test,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
欢迎来到Cefler的博客😁
🕌博客主页:那个传说中的man的主页
🏠个人专栏:题目解析
🌎推荐文章:题目大解析(3)
目录
- 👉🏻第四周
- 素数和
- 念整数
👉🏻第四周
素数和
import java.util.Scanner;
public class Main {static public boolean IsPrime(int n){if(n>1) {for(int i = 2;i<n;i++){if(n%i==0)return false;}return true;}return false;}public static void main(String args[]) {int n,m;Scanner input = new Scanner(System.in);n = input.nextInt();m = input.nextInt();int[] arr = new int[m-n+1];//输入数据int sum = 0,count = 0,i=2;while(count<m) {if(IsPrime(i))count++;if(IsPrime(i)&&count>=n){sum+=i;}++i;}System.out.println(sum);}
}
念整数
import java.util.Scanner;
public class Main {public static void main(String args[]) {String n = new Scanner(System.in).nextLine();String[] str = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};for(int i = 0;i<n.length();i++){int index = n.charAt(i) - '0';if(i==0&&n.charAt(0)=='-')System.out.print("fu");else{if(i==0)System.out.print(str[index]);elseSystem.out.print(" "+str[index]);}}}
}
真心不喜欢java
这篇关于School‘s Java test的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!