当前位置:网站首页>Blue Bridge Cup basic-15 VIP question string comparison
Blue Bridge Cup basic-15 VIP question string comparison
2022-06-12 19:56:00 【Hua Weiyun】
test questions Based on practice String comparison
1: Two strings are not the same length . such as Beijing and Hebei
2: Two strings are not only equal in length , And the characters in the corresponding positions are exactly the same ( Case sensitive ), such as Beijing and Beijing
3: Two strings are equal in length , The characters in the corresponding positions can be completely consistent only if they are not case sensitive ( in other words , It's not satisfied with the situation 2). such as beijing and BEIjing
4: Two strings are equal in length , But even case insensitive doesn't make the two strings consistent . such as Beijing and Nanjing
Programming determines which of these four categories is the relationship between the two input strings , Give the number of the class .
beiJing import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String str1 = scanner.next();
String str2 = scanner.next();
if (str1.length() != str2.length()) { //1: Two strings are not the same length .
System.out.println(1);
} else {
if (str1.equals(str2)) { //2: Two strings are not only equal in length , And the characters in the corresponding positions are exactly the same ( Case sensitive )
System.out.println(2);
}else if (str1.equalsIgnoreCase(str2)) { //3: Two strings are equal in length , The characters in the corresponding positions can be completely consistent only if they are not case sensitive
System.out.println(3);
}else { //4: Two strings are equal in length , But even case insensitive doesn't make the two strings consistent .
System.out.println(4);
}
}
}
}
The demonstration effect is as follows --

I hope this article can help you !
Thank you. !
边栏推荐
- Kyma application connectivity feature introduction
- Wechat e-book reading applet graduation design completion works (8) graduation design thesis template
- torch 网络模型转换onnx格式,并可视化
- 登录mysql
- Axure RP 9 for MAC (interactive product prototyping tool) Chinese version
- Demand and business model innovation - demand 1 - Introduction to demand engineering
- synchronized下的 i+=2 和 i++ i++执行结果居然不一样
- golang类型断言理解[go语言圣经]
- MySQL - the execution order of an SQL statement
- What is data driven
猜你喜欢

【生成对抗网络学习 其三】BiGAN论文阅读笔记及其原理理解

2 R programming

基于微信电子书阅读小程序毕业设计毕设作品(4)开题报告

BigTable (II): how BigTable achieves scalability and high performance

【GAMES101】课堂笔记8–着色(着色频率、图形管线、纹理映射)

Negative remainder problem

Axure RP 9 for MAC (interactive product prototyping tool) Chinese version

Wechat e-book reading applet graduation design completion works (8) graduation design thesis template

Promise to solve hell function calls can be used infinitely

2022年最新宁夏建筑安全员模拟题库及答案
随机推荐
Torch network model is converted to onnx format and visualized
MySQL - the execution order of an SQL statement
System log
Understanding of data in memory
登录mysql
BigTable (II): how BigTable achieves scalability and high performance
PostgreSQL database replication - background first-class citizen process walreceiver PG_ stat_ wal_ Receiver view
Axure RP 9 for MAC (interactive product prototyping tool) Chinese version
7:00 tonight | application of PhD debate self supervised learning in Recommendation System
模块八作业
API call display, detailed API of Taobao, tmall and pinduoduo commodity pages, and return of APP side original data parameters
Microsoft Word 教程,如何在 Word 中插入页码、目录?
Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
Connectez - vous à MySQL
Parameter meaning of random forest randomforestclassifier in sklearn
Process creation fork (), demise wait()
Download and configuration of nuitka packaging tutorial
Hardware test - why not use grounding clip for ripple test
负数取余问题
Demand and business model innovation-4-strategy