当前位置:网站首页>【每日一题】第一天
【每日一题】第一天
2022-07-02 17:09:00 【亚太地区百大最帅面孔第101名】
️ Author: 老九
️ 个人博客:老九的CSDN博客
个人名言:不可控之事 乐观面对
系列专栏:每日一题
选择

Character是包装类,不能存放字符串常量,String可以,StringBuffer需要new对象才能使用,Vector是集合

方法的重写:存在继承关系,子类需要的方法父类无法满足, 子类方法重写的权限大小必须要大于父类,其他都一样

结构化程序设计原则:模块化,自顶向下,逐步求精

成员变量没有初始化默认给0

java中求余可以带小数,C语言不行





静态方法才能用类名访问
编程题1

分组方式可以先从小到大排序,然后拿第一个和最后两个凑为一组
公式:arr.len-2*(i+1)
public class test1 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (scan.hasNextInt()) {
int n = scan.nextInt();
int[] array = new int[3 * n];
long sum = 0;
for (int i = 0; i < 3 * n; i++) {
array[i] = scan.nextInt();
}
Arrays.sort(array);
for (int i = 0; i < n; i++) {
sum += array[array.length - 2 * (i + 1)];
}
System.out.println(sum);
}
}
}
编程题2

1.遍历str2这个字符串,把对应的字符放到hash[]
2.遍历str1,找到 == 0的才是要的字符
public class test1 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String str1 = scan.nextLine();
String str2 = scan.nextLine();
HashMap<Character,Integer> map = new HashMap();
for(int i = 0;i<str2.length();i++){
if(map.get(str2.charAt(i)) == null){
map.put(str2.charAt(i),1);
}else{
map.put(str2.charAt(i),map.get(str2.charAt(i))+1);
}
}
String ret = "";
for(int i = 0;i< str1.length();i++){
if(map.get(str1.charAt(i)) == null){
ret += str1.charAt(i);
}
}
System.out.println(ret);
}
}
————————————————————————
码字不易,大家的支持就是我坚持下去的动力
版权声明:本文为CSDN博主「亚太地区百大最帅面孔第101名」的原创文章
边栏推荐
- Three ways of function parameter transfer in C language
- 文字编辑器 希望有错误的句子用红色标红,文字编辑器用了markdown
- 再放寬!這些應届生,可直接落戶上海
- 昨天阿里学长写了一个责任链模式,竟然出现了无数个bug
- Which securities company has a low, safe and reliable online account opening commission
- Qt Official examples: Qt Quick Controls - Gallery
- 彻底搞懂基于Open3D的点云处理教程!
- ESP32-C3入门教程 问题篇⑪——esp-tls: create_ssl_handle failed, tls_io_instance->options.trusted_certs null
- Another double non reform exam 408, will it be cold? Software College of Nanchang Aviation University
- 初夏,开源魔改一个带击杀音效的电蚊拍!
猜你喜欢

ESP32-C3入门教程 问题篇⑩——error: implicit declaration of function ‘esp_blufi_close‘;

A good programmer is worth five ordinary programmers!

阿里三面被面试官狂问Redis,简历上再也不敢写'精通'了

彻底搞懂基于Open3D的点云处理教程!

SteamOS 3.3 Beta 发布,Steam Deck 中文键盘终于来了

UE4 用spline画正圆

再放宽!这些应届生,可直接落户上海

UE4 用spline畫正圓

Wechat applet video sharing platform system graduation design completion (1) development outline

Wechat applet video sharing platform system graduation design completion (4) opening report
随机推荐
【西北工业大学】考研初试复试资料分享
Nm02 nm module call sequence diagram and code interpretation independent of bus protocol
呆错图床系统源码图片CDN加速与破J防盗链功能
Leetcode 面试题 16.11. 跳水板
A good programmer is worth five ordinary programmers!
Leetcode 面试题 16.17. 连续数列
Memory mapping of QT
Qt Official examples: Qt Quick Controls - Gallery
饭卡 HDU2546
@Component cannot get Dao layer
UE4 用spline画正圆
QQmlApplicationEngine
Wechat applet video sharing platform system graduation design (3) background function
谷歌官方回应:我们没有放弃TensorFlow,未来与JAX并肩发展
Redis(6)----对象与数据结构
Steamos 3.3 beta release, steam deck Chinese keyboard finally came
文字编辑器 希望有错误的句子用红色标红,文字编辑器用了markdown
Leetcode interview question 17.01 Addition without plus sign
719. 找出第 K 小的数对距离
iframe嵌套详解