没有合适的资源?快使用搜索试试~ 我知道了~
华为JAVA考试试题.docx
1 下载量 128 浏览量
2023-07-12
12:21:06
上传
评论
收藏 20KB DOCX 举报
温馨提示
试读
29页
华为JAVA考试试题.docx
资源推荐
资源详情
资源评论
华为 JAVA 考试试题
1.程序实现目标: 输入一个字符串,将其各个字符对应的 ASCII 值
加 5 后,输出结果。
程序要求:该字符串只包含小写字母,若其值加 5 后的字符值大于
z,将其转换成从 a 开头的字符。
package com.xcbeyond;
/**
* @author xcbeyond
* 2023-5-7 下午 10:37:43
* 1.程序实现目标: 输入一个字符串,将其各个字符对应的 ASCII
值加 5 后,输出结果。
* 程序要求:该字符串只包含小写字母,若其值加 5 后的字符值大于
z,将其转换成从 a 开头的字符。
*/
public class StringParseASCII {
public static void main(String[] args) {
System.out.print(stringParseASCII(abx));
}
public static String stringParseASCII(String str){
StringBuffer result = new StringBuffer();
char tmp;
for(int i = 0;i
int[] tmp = arr[i];
Arrays.sort(tmp);
minArr[i] = tmp[0];
}
return minArr;
}
}
9. 输入:a aa,cat tiger.123dd
输出: tiger
功能描述:键盘输入一句话
输出一句话中最常的单词,假如最长的消失屡次,返回第一个。
这句话只包含数字字母和标点。
package com.xcbeyond;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author xcbeyond
* 2023-5-10 下午 09:45:03
*9. 输入:a aa,cat tiger.123dd
* 输出: tiger
* 功能描述:键盘输入一句话
* 输出一句话中最常的单词,假如最长的消失屡次,返回第一个。
* 这句话只包含数字字母和标点。
*/
public class GetLongString {
public static void main(String[] args) {
System.out.println(请输入一句话:);
Scanner console = new Scanner(System.in);
String str = console.nextLine();
System.out.println(最长的单词为:+getLongString(str));
}
public static String getLongString(String str) {
String[] wordStr = str.split([ ,.0-9]);
int sum = 0;
ArrayList list = new ArrayList
if(dataStr[i] == 0) {
dataStr[i] = 1;
}else {
dataStr[i] = 0;
}
}
String str = ;
for(int i = 0 ;i
str += dataStr[i];
}
String res = Integer.valueOf(str, 2).toString();
return res;
}
}
18. 功能描述:推断一个字符串中的( )是否配对
输入:if(a.equals(a))
输出:true
package com.xcbeyond;
/**
* @author xcbeyond
* @date 2023/05/11 15:50:39
*/
public class IsMatch {
public static void main(String[] args) {
String str = if(a.equals(a));
System.out.println(isMatch(str));
}
public static boolean isMatch(String str){
boolean isMatch = false;
char[] ch = str.toCharArray();
int count = 0;
for(int i = 0 ;i
if(ch[i] == () {
count++;
}else if(ch[i] == )) {
count--;
}
}
if(count == 0) {
isMatch = true;
}
剩余28页未读,继续阅读
资源评论
Mmnnnbb123
- 粉丝: 688
- 资源: 8万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功