当前位置: 首页 > 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 离线安装指南

参考文章 1、确认操作系统类型及内核版本 Docker依赖于Linux内核的一些特性&#xff0c;不同版本的Docker对内核版本有不同要求。例如&#xff0c;Docker 17.06及之后的版本通常需要Linux内核3.10及以上版本&#xff0c;Docker17.09及更高版本对应Linux内核4.9.x及更高版本。…...

智能在线客服平台:数字化时代企业连接用户的 AI 中枢

随着互联网技术的飞速发展&#xff0c;消费者期望能够随时随地与企业进行交流。在线客服平台作为连接企业与客户的重要桥梁&#xff0c;不仅优化了客户体验&#xff0c;还提升了企业的服务效率和市场竞争力。本文将探讨在线客服平台的重要性、技术进展、实际应用&#xff0c;并…...

生成 Git SSH 证书

&#x1f511; 1. ​​生成 SSH 密钥对​​ 在终端&#xff08;Windows 使用 Git Bash&#xff0c;Mac/Linux 使用 Terminal&#xff09;执行命令&#xff1a; ssh-keygen -t rsa -b 4096 -C "your_emailexample.com" ​​参数说明​​&#xff1a; -t rsa&#x…...

自然语言处理——Transformer

自然语言处理——Transformer 自注意力机制多头注意力机制Transformer 虽然循环神经网络可以对具有序列特性的数据非常有效&#xff0c;它能挖掘数据中的时序信息以及语义信息&#xff0c;但是它有一个很大的缺陷——很难并行化。 我们可以考虑用CNN来替代RNN&#xff0c;但是…...

如何在最短时间内提升打ctf(web)的水平?

刚刚刷完2遍 bugku 的 web 题&#xff0c;前来答题。 每个人对刷题理解是不同&#xff0c;有的人是看了writeup就等于刷了&#xff0c;有的人是收藏了writeup就等于刷了&#xff0c;有的人是跟着writeup做了一遍就等于刷了&#xff0c;还有的人是独立思考做了一遍就等于刷了。…...

Rapidio门铃消息FIFO溢出机制

关于RapidIO门铃消息FIFO的溢出机制及其与中断抖动的关系&#xff0c;以下是深入解析&#xff1a; 门铃FIFO溢出的本质 在RapidIO系统中&#xff0c;门铃消息FIFO是硬件控制器内部的缓冲区&#xff0c;用于临时存储接收到的门铃消息&#xff08;Doorbell Message&#xff09;。…...

Java + Spring Boot + Mybatis 实现批量插入

在 Java 中使用 Spring Boot 和 MyBatis 实现批量插入可以通过以下步骤完成。这里提供两种常用方法&#xff1a;使用 MyBatis 的 <foreach> 标签和批处理模式&#xff08;ExecutorType.BATCH&#xff09;。 方法一&#xff1a;使用 XML 的 <foreach> 标签&#xff…...

Go 并发编程基础:通道(Channel)的使用

在 Go 中&#xff0c;Channel 是 Goroutine 之间通信的核心机制。它提供了一个线程安全的通信方式&#xff0c;用于在多个 Goroutine 之间传递数据&#xff0c;从而实现高效的并发编程。 本章将介绍 Channel 的基本概念、用法、缓冲、关闭机制以及 select 的使用。 一、Channel…...

LangFlow技术架构分析

&#x1f527; LangFlow 的可视化技术栈 前端节点编辑器 底层框架&#xff1a;基于 &#xff08;一个现代化的 React 节点绘图库&#xff09; 功能&#xff1a; 拖拽式构建 LangGraph 状态机 实时连线定义节点依赖关系 可视化调试循环和分支逻辑 与 LangGraph 的深…...

提升移动端网页调试效率:WebDebugX 与常见工具组合实践

在日常移动端开发中&#xff0c;网页调试始终是一个高频但又极具挑战的环节。尤其在面对 iOS 与 Android 的混合技术栈、各种设备差异化行为时&#xff0c;开发者迫切需要一套高效、可靠且跨平台的调试方案。过去&#xff0c;我们或多或少使用过 Chrome DevTools、Remote Debug…...