当前位置:网站首页>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. !
边栏推荐
- MySQL - the execution order of an SQL statement
- What is a federated index?
- Demand and business model analysis-2-business model types
- Microsoft Word tutorial, how to insert page numbers and table of contents in word?
- Parameter meaning of random forest randomforestclassifier in sklearn
- Demand and business model analysis-3-design
- 94. analyze the content in the web page
- Torch network model is converted to onnx format and visualized
- 基于微信电子书阅读小程序毕业设计毕设作品(5)任务书
- Optimization of SQL statements
猜你喜欢

Demand and business model analysis -6- five topics

Storage system overview

Basic structure of arithmetic unit

PostgreSQL数据库复制——后台一等公民进程WalReceiver pg_stat_wal_receiver视图

负数取余问题

基于微信电子书阅读小程序毕业设计毕设作品(2)小程序功能

3 R complex data types

Understanding of data in memory

Using / developing private plug-ins in traifik proxy 2.5 (traifik official blog)

Microsoft Word tutorial, how to insert page numbers and table of contents in word?
随机推荐
Reading small programs based on wechat e-book graduation design works (7) Interim inspection report
Demand and business model analysis-1-business model canvas
Axure RP 9 for MAC (interactive product prototyping tool) Chinese version
Demand and business model analysis-3-design
What is a federated index?
Since using low code development, the development efficiency has been increased by 10 times
新来的同事问我 where 1=1 是什么意思???
BigTable (II): how BigTable achieves scalability and high performance
Stm8l51 sx1280 commissioning record
Ctfshow-web266 (deserialization)
登錄mysql
3 R complex data types
7 R read / write data
Demand and business model analysis -6- five topics
Microsoft Word 教程,如何在 Word 中插入页码、目录?
The component style set by uniapp takes effect in H5 and app, but does not take effect in wechat applet. The problem is solved
Basic structure of arithmetic unit
登录mysql
[splishsplash] custom exporter
The joint empowerment plan of Baidu PaddlePaddle large enterprise open innovation center was launched! Help Pudong to upgrade its industry intelligently