当前位置: 首页 > news >正文

蓝桥杯Java组备赛(二)

题目1
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int max = Integer.MIN_VALUE;int min = Integer.MAX_VALUE;double sum = 0;for(int i=0;i<n;i++) {int x = sc.nextInt();max = Math.max(max, x);min = Math.min(min, x);sum+=x;}System.out.println(max);System.out.println(min);System.out.printf("%.2f",sum/n);sc.close();}
}

题目2
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);
//		if((2021%400 == 0)||(2021%100!=0 && 2021%4 == 0))
//			System.out.println("yes");int[] date = {0,31,28,31,30,31,30,31,31,30,31,30,31};int y = sc.nextInt();int r = sc.nextInt();// if(y == 2) {// 	if(r > 28) {// 		System.out.println("no");// 		return ;// 	}else {// 		System.out.println("yes");// 		return ;// 	}// }for(int i=1;i<=12;i++) {if(y == i) {for(int j=1;j<=date[i];j++) {if(r == j) {System.out.println("yes");return ;}}}}System.out.println("no");sc.close();}
}

题目3
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int a = sc.nextInt();int b = sc.nextInt();int t = sc.nextInt();//分钟		int c1 = t/60;int c2 = t%60;a = a + c1;b = b + c2;if(b>=60) {a = a + b/60;b%=60;}System.out.println(a);System.out.println(b);sc.close();}
}

题目4
在这里插入图片描述
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int m = sc.nextInt();int[][] res = new int[n][m];int[][] sum = new int[n][m];for(int i=0;i<n;i++) {for(int j=0;j<m;j++) {res[i][j] = sc.nextInt();if(res[i][j] == 1) {sum[i][j] = 9;}}}for(int i=0;i<n;i++) {for(int j=0;j<m;j++) {if(res[i][j]!=1) {for(int x=i-1;x<=(i+1);x++) {for(int y=j-1;y<=(j+1);y++) {if((x>=0 && x<=(n-1))&&(y>=0 && y<=(m-1))&& res[x][y] == 1) {sum[i][j]++;}}}}}}for(int i=0;i<n;i++) {for(int j=0;j<m;j++) {System.out.print(sum[i][j]+" ");}System.out.println();}sc.close();}
}

题目5
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);char[] c = sc.next().toCharArray();for(int i=0;i<c.length;i++) {if(c[i]>='a'&&c[i]<='z') {c[i]^=32;}}System.out.println(c);sc.close();}
}

题目6
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String s = sc.nextLine();String[] ss = s.split(" ");int sum = 0;for(int i=0;i<ss.length;i++) {sum+=ss[i].length();}System.out.println(sum);sc.close();}
}

题目7
在这里插入图片描述

public class Main {public static int res(int x) {int xx = x;while(xx!=0) {int t = xx%10;if(t == 2 || t == 0 || t == 1 || t == 9) {return x;}xx/=10;}return 0;}public static void main(String[] args) {int sum = 0;for(int i=1;i<=2019;i++) {sum+=res(i);}System.out.println(sum);}
}

题目8
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int[] date= {0,31,28,31,30,31,30,31,31,30,31,30,31};int n = sc.nextInt();for(int i=1;i<=12;i++) {if(n == i) {System.out.println(date[i]);return ;}}sc.close();}
}

题目9
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int[] res = new int[n];for(int i=0;i<n;i++)res[i] = sc.nextInt();int sum = 0;for(int i=1;i<n;i++) {sum = Math.max(sum, res[i]-res[i-1]);}System.out.println(sum);sc.close();}
}

题目10
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {	Scanner sc = new Scanner(System.in);int n = sc.nextInt();int x = 1;int y = 0;//记录加的次数int sum = 0;//记录输出结果int i=1;//加的次数等于n时候结束for(;y<n;) {sum+=i;x-=1;y+=1;if(x == 0) {i++;x = i;}}System.out.println(sum);sc.close();		}
}

题目11
在这里插入图片描述

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;public class Main {public static void main(String[] args) {//去重与排序Scanner sc = new Scanner(System.in);int n = sc.nextInt();Set<Integer> set = new HashSet<>();List<Integer> list = new LinkedList<>();// List<Integer> list = new ArrayList<>();for(int i=0;i<n;i++) {int x = sc.nextInt();if(!set.contains(x)) {set.add(x);list.add(x);}}Collections.sort(list);System.out.println(list.size());for(int x:list) {System.out.print(x+" ");}sc.close();}
}

题目12
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {//0 2 0 0 0 0//2 * 2 2 0 0//0 2 2 * 2 0Scanner sc = new Scanner(System.in);int n = sc.nextInt();int m = sc.nextInt();int t = sc.nextInt();int[][] res = new int[n+1][m+1];int[][] ure = new int[n+1][m+1];for(int i=1;i<=t;i++) {int x = sc.nextInt();int y = sc.nextInt();res[x][y] = 1;ure[x][y] = 1;	}int k = sc.nextInt();int sum = t;while(k!=0) {for(int i=1;i<=n;i++) {for(int j=1;j<=m;j++) {if(res[i][j] == 1 && ure[i][j] == 1) {if((i-1)>=1 && (i-1)<=n && res[i-1][j] != 1) {res[i-1][j] = 1;sum+=1;}if((i+1)>=1 && (i+1)<=n && res[i+1][j] != 1) {res[i+1][j] = 1;sum+=1;}if((j-1)>=1 && (j-1)<=m && res[i][j-1] != 1) {res[i][j-1] = 1;sum+=1;}if((j+1)>=1 && (j+1)<=m && res[i][j+1] != 1) {res[i][j+1] = 1;sum+=1;}}}}k--;}System.out.println(sum);sc.close();		}
}

题目13
在这里插入图片描述

public class Main {public static void main(String[] args) {int res = 0;int[] date = {0,31,28,31,30,31,30,31,31,30,31,30,31};for(int i=1900;i<=9999;i++) {if((i%400 == 0)||(i%100!=0 && i%4 == 0))date[2] = 29;elsedate[2] = 28; 	//一定要加这个else,否则闰年过后2月还是29天,没改回来for(int j=1;j<=12;j++) {for(int k=1;k<=date[j];k++) {int key1 = i;int sum1 = 0;while(key1!=0) {int t1 = key1%10;sum1 += t1;key1/=10;}//--int key2 = j;int sum2 = 0;while(key2!=0) {int t2 = key2%10;sum2 += t2;key2/=10;}//--int key3 = k;int sum3 = 0;while(key3!=0) {int t3 = key3%10;sum3 += t3;key3/=10;}if(sum1 == (sum2+sum3))res++;}}}System.out.println(res);}
}

题目14
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int[] res = new int[n+1];for(int i=1;i<=n;i++) {res[i] = sc.nextInt();}int ans = 0;for(int i=1;i<=n;i++) {for(int j=i+1;j<=n;j++) {ans = Math.max(ans, Math.abs(i-j)+Math.abs(res[i]-res[j]));}}System.out.println(ans);sc.close();}
}

题目15
在这里插入图片描述

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int[] res = new int[n+1];for(int i=1;i<=n;i++)res[i] = sc.nextInt();int ans = 0;int max = 0;for(int i=1;i<n;i++) {if(res[i]<res[i+1])ans++;else {max = Math.max(max, ans);ans = 0;}}System.out.println(max+1);sc.close();}
}

相关文章:

蓝桥杯Java组备赛(二)

题目1 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int n sc.nextInt();int max Integer.MIN_VALUE;int min Integer.MAX_VALUE;double sum 0;for(int i0;i<n;i) {int x sc.nextInt()…...

人力资源智能化管理项目(day10:首页开发以及上线部署)

学习源码可以看我的个人前端学习笔记 (github.com):qdxzw/humanResourceIntelligentManagementProject 首页-基本结构和数字滚动 安装插件 npm i vue-count-to <template><div class"dashboard"><div class"container"><!-- 左侧内…...

Conda管理Python不同版本教程

Conda管理Python不同版本教程 目录 0.前提 1.conda常用命令 2.conda设置国内源&#xff08;以添加清华源为例&#xff0c;阿里云源同样&#xff09; 3.conda管理python库 4.其它 不太推荐 pyenv管理Python不同版本教程&#xff08;本人另一篇博客&#xff0c;姊妹篇&…...

free pascal:fpwebview 组件通过 JSBridge 调用本机TTS

从 https://github.com/PierceNg/fpwebview 下载 fpwebview-master.zip 简单易用。 先请看 \fpwebview-master\README.md cd \lazarus\projects\fpwebview-master\demo\js_bidir 学习 js_bidir.lpr &#xff0c;编写 js_bind_speak.lpr 如下&#xff0c;通过 JSBridge 调用本…...

数据结构——单链表专题

目录 1. 链表的概念及结构2. 实现单链表初始化尾插头插尾删头删查找在指定位置之前插入数据在指定位置之后插入数据删除指定位之前的节点删除指定位置之后pos节点销毁链表 3. 完整代码test.cSList.h 4. 链表的分类 1. 链表的概念及结构 在顺序表中存在一定的问题&#xff1a; …...

Linux:开源世界的王者

在科技世界中&#xff0c;Linux犹如一位低调的王者&#xff0c;统治着开源世界的半壁江山。对于许多技术爱好者、系统管理员和开发者来说&#xff0c;Linux不仅仅是一个操作系统&#xff0c;更是一种信仰、一种哲学。 一、开源的魅力 Linux的最大魅力在于其开源性质。与封闭的…...

⭐北邮复试刷题103. 二叉树的锯齿形层序遍历 (力扣每日一题)

103. 二叉树的锯齿形层序遍历 给你二叉树的根节点 root &#xff0c;返回其节点值的 锯齿形层序遍历 。&#xff08;即先从左往右&#xff0c;再从右往左进行下一层遍历&#xff0c;以此类推&#xff0c;层与层之间交替进行&#xff09;。 示例 1&#xff1a;输入&#xff1a…...

文件上传漏洞--Upload-labs--Pass07--点绕过

一、什么是点绕过 在Windows系统中&#xff0c;Windows特性会将文件后缀名后多余的点自动删除&#xff0c;在网页源码中&#xff0c;通常使用 deldot()函数 对点进行去除&#xff0c;若发现网页源代码中没有 deldot() 函数&#xff0c;则可能存在 点绕过漏洞。通过点绕过漏洞&…...

MySQL高级特性篇(1)-JSON数据类型的应用

MySQL是一种常用的关系型数据库管理系统&#xff0c;它提供了多种数据类型&#xff0c;其中包括JSON数据类型。JSON&#xff08;JavaScript Object Notation&#xff09;是一种常用的数据交换格式&#xff0c;它以键值对的形式组织数据&#xff0c;并支持嵌套和数组结构。MySQL…...

如何用Qt实现一个无标题栏、半透明、置顶(悬浮)的窗口

在Qt框架中&#xff0c;要实现一个无标题栏、半透明、置顶&#xff08;悬浮&#xff09;的窗口&#xff0c;需要一些特定的设置和技巧。废话不多说&#xff0c;下面我将以DrawClient软件为例&#xff0c;介绍一下实现这种效果的四个要点。 要点一&#xff1a;移除标题栏&#…...

ViT: transformer在图像领域的应用

文章目录 1. 概要2. 方法3. 实验3.1 Compare with SOTA3.2 PRE-TRAINING DATA REQUIREMENTS3.3 SCALING STUDY3.4 自监督学习 4. 总结参考 论文&#xff1a; An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale 代码&#xff1a;https://github.com…...

Sora 的工作原理(及其意义)

原文&#xff1a;How Sora Works (And What It Means) 作者&#xff1a; DAN SHIPPER OpenAI 的新型文本到视频模型为电影制作开启了新篇章 DALL-E 提供的插图。 让我们先明确一点&#xff0c;我们不会急急忙忙慌乱。我们不会预测乌托邦或预言灾难。我们要保持冷静并... 你…...

Java学习笔记2024/2/16

知识点 面向对象 题目1&#xff08;完成&#xff09; 定义手机类&#xff0c;手机有品牌(brand),价格(price)和颜色(color)三个属性&#xff0c;有打电话call()和sendMessage()两个功能。 请定义出手机类&#xff0c;类中要有空参、有参构造方法&#xff0c;set/get方法。 …...

XLNet做文本分类

import torch from transformers import XLNetTokenizer, XLNetForSequenceClassification from torch.utils.data import DataLoader, TensorDataset # 示例文本数据 texts ["This is a positive example.", "This is a negative example.", "Anot…...

Swift 5.9 新 @Observable 对象在 SwiftUI 使用中的陷阱与解决

概览 在 Swift 5.9 中&#xff0c;苹果为我们带来了全新的可观察框架 Observation&#xff0c;它是观察者开发模式在 Swift 中的一个全新实现。 除了自身本领过硬以外&#xff0c;Observation 框架和 SwiftUI 搭配起来也能相得益彰&#xff0c;事倍功半。不过 Observable 对象…...

分享一个学英语的网站

名字叫&#xff1a;公益大米网​​​​​​​ Freerice 这个网站是以做题的形式来记忆单词&#xff0c;题干是一个单词&#xff0c;给出4个选项&#xff0c;需要选出其中最接近题干单词的选项。 答对可以获得10粒大米&#xff0c;网站的创办者负责捐赠。如图 触发某些条件&a…...

【动态规划】【C++算法】2742. 给墙壁刷油漆

作者推荐 【数位dp】【动态规划】【状态压缩】【推荐】1012. 至少有 1 位重复的数字 本文涉及知识点 动态规划汇总 LeetCode2742. 给墙壁刷油漆 给你两个长度为 n 下标从 0 开始的整数数组 cost 和 time &#xff0c;分别表示给 n 堵不同的墙刷油漆需要的开销和时间。你有…...

【后端高频面试题--设计模式上篇】

&#x1f680; 作者 &#xff1a;“码上有前” &#x1f680; 文章简介 &#xff1a;后端高频面试题 &#x1f680; 欢迎小伙伴们 点赞&#x1f44d;、收藏⭐、留言&#x1f4ac; 往期精彩内容 【后端高频面试题–设计模式上篇】 【后端高频面试题–设计模式下篇】 【后端高频…...

P3141 [USACO16FEB] Fenced In P题解

题目 如果此题数据要小一点&#xff0c;那么我们可以用克鲁斯卡尔算法通过&#xff0c;但是这个数据太大了&#xff0c;空间会爆炸&#xff0c;时间也会爆炸。 我们发现&#xff0c;如果用 MST 做&#xff0c;那么很多边的边权都一样&#xff0c;我们可以整行整列地删除。 我…...

Android Compose 一个音视频APP——Magic Music Player

Magic Music APP Magic Music APP Magic Music APP概述效果预览-视频资源功能预览Library歌曲播放效果预览歌曲播放依赖注入设置播放源播放进度上一首&下一首UI响应 歌词歌词解析解析成行逐行解析 视频播放AndroidView引入Exoplayer自定义Exoplayer样式横竖屏切换 歌曲多任…...

使用docker在3台服务器上搭建基于redis 6.x的一主两从三台均是哨兵模式

一、环境及版本说明 如果服务器已经安装了docker,则忽略此步骤,如果没有安装,则可以按照一下方式安装: 1. 在线安装(有互联网环境): 请看我这篇文章 传送阵>> 点我查看 2. 离线安装(内网环境):请看我这篇文章 传送阵>> 点我查看 说明&#xff1a;假设每台服务器已…...

基于服务器使用 apt 安装、配置 Nginx

&#x1f9fe; 一、查看可安装的 Nginx 版本 首先&#xff0c;你可以运行以下命令查看可用版本&#xff1a; apt-cache madison nginx-core输出示例&#xff1a; nginx-core | 1.18.0-6ubuntu14.6 | http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages ng…...

ffmpeg(四):滤镜命令

FFmpeg 的滤镜命令是用于音视频处理中的强大工具&#xff0c;可以完成剪裁、缩放、加水印、调色、合成、旋转、模糊、叠加字幕等复杂的操作。其核心语法格式一般如下&#xff1a; ffmpeg -i input.mp4 -vf "滤镜参数" output.mp4或者带音频滤镜&#xff1a; ffmpeg…...

Caliper 配置文件解析:config.yaml

Caliper 是一个区块链性能基准测试工具,用于评估不同区块链平台的性能。下面我将详细解释你提供的 fisco-bcos.json 文件结构,并说明它与 config.yaml 文件的关系。 fisco-bcos.json 文件解析 这个文件是针对 FISCO-BCOS 区块链网络的 Caliper 配置文件,主要包含以下几个部…...

【论文阅读28】-CNN-BiLSTM-Attention-(2024)

本文把滑坡位移序列拆开、筛优质因子&#xff0c;再用 CNN-BiLSTM-Attention 来动态预测每个子序列&#xff0c;最后重构出总位移&#xff0c;预测效果超越传统模型。 文章目录 1 引言2 方法2.1 位移时间序列加性模型2.2 变分模态分解 (VMD) 具体步骤2.3.1 样本熵&#xff08;S…...

【开发技术】.Net使用FFmpeg视频特定帧上绘制内容

目录 一、目的 二、解决方案 2.1 什么是FFmpeg 2.2 FFmpeg主要功能 2.3 使用Xabe.FFmpeg调用FFmpeg功能 2.4 使用 FFmpeg 的 drawbox 滤镜来绘制 ROI 三、总结 一、目的 当前市场上有很多目标检测智能识别的相关算法&#xff0c;当前调用一个医疗行业的AI识别算法后返回…...

Unity | AmplifyShaderEditor插件基础(第七集:平面波动shader)

目录 一、&#x1f44b;&#x1f3fb;前言 二、&#x1f608;sinx波动的基本原理 三、&#x1f608;波动起来 1.sinx节点介绍 2.vertexPosition 3.集成Vector3 a.节点Append b.连起来 4.波动起来 a.波动的原理 b.时间节点 c.sinx的处理 四、&#x1f30a;波动优化…...

2025季度云服务器排行榜

在全球云服务器市场&#xff0c;各厂商的排名和地位并非一成不变&#xff0c;而是由其独特的优势、战略布局和市场适应性共同决定的。以下是根据2025年市场趋势&#xff0c;对主要云服务器厂商在排行榜中占据重要位置的原因和优势进行深度分析&#xff1a; 一、全球“三巨头”…...

Linux 内存管理实战精讲:核心原理与面试常考点全解析

Linux 内存管理实战精讲&#xff1a;核心原理与面试常考点全解析 Linux 内核内存管理是系统设计中最复杂但也最核心的模块之一。它不仅支撑着虚拟内存机制、物理内存分配、进程隔离与资源复用&#xff0c;还直接决定系统运行的性能与稳定性。无论你是嵌入式开发者、内核调试工…...

免费PDF转图片工具

免费PDF转图片工具 一款简单易用的PDF转图片工具&#xff0c;可以将PDF文件快速转换为高质量PNG图片。无需安装复杂的软件&#xff0c;也不需要在线上传文件&#xff0c;保护您的隐私。 工具截图 主要特点 &#x1f680; 快速转换&#xff1a;本地转换&#xff0c;无需等待上…...