School‘s Java test

欢迎来到Cefler的博客😁

🕌博客主页:那个传说中的man的主页

🏠个人专栏:题目解析

🌎推荐文章:题目大解析(3)


目录

👉🏻第四周

素数和

cpp 复制代码
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);
	}
}

念整数

java 复制代码
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]);
				else
				System.out.print(" "+str[index]);
			}
		}
		
	}
}

真心不喜欢java

相关推荐
lUie INGA4 小时前
在2023idea中如何创建SpringBoot
java·spring boot·后端
小糖学代码4 小时前
LLM系列:1.python入门:15.JSON 数据处理与操作
开发语言·python·json·aigc
handler014 小时前
从源码到二进制:深度拆解 Linux 下 C 程序的编译与链接全流程
linux·c语言·开发语言·c++·笔记·学习
geBR OTTE5 小时前
SpringBoot中整合ONLYOFFICE在线编辑
java·spring boot·后端
Porunarufu5 小时前
博客系统UI自动化测试报告
java
小白学大数据5 小时前
现代Python爬虫开发范式:基于Asyncio的高可用架构实战
开发语言·爬虫·python·架构
渔舟小调5 小时前
P19 | 前端加密通信层 pikachuNetwork.js 完整实现
开发语言·前端·javascript
不爱吃炸鸡柳5 小时前
数据结构精讲:树 → 二叉树 → 堆 从入门到实战
开发语言·数据结构
网络安全许木5 小时前
自学渗透测试第21天(基础命令复盘与DVWA熟悉)
开发语言·网络安全·渗透测试·php
t***5445 小时前
如何在Dev-C++中使用Clang编译器
开发语言·c++