当前位置:网站首页>Prepare for the interview and stick to the third sentence of the question - Branch sentences!
Prepare for the interview and stick to the third sentence of the question - Branch sentences!
2022-07-28 00:14:00 【_ Great intelligence】
This column 『 Hundred days and hundred questions 』 Long term renewal , Join this question brushing plan , Grow up together !
List of articles
Preface
How to brush questions ?
Some students just like it , It's the ultimate difficulty , I feel that as long as I make the most difficult , The rest is easily solved . This kind of eager thought should not .
Algorithm training is a systematic project , need Step by step , Too eager for quick success and instant benefit , Instead, it is easy to feel frustrated because you can't solve problems , Counterproductive .
I remember one of my colleagues did something similar . I just heard about Cattle from , Just want to try it , After he went up, he picked a difficult topic , As a result, I thought for a long time and didn't do it , Get yourself particularly depressed .
You will find that this practice is inefficient , Even if the problem is solved , It doesn't mean you can solve other problems .
The reasonable way is to go step by step .
My suggestion is to brush the basic grammar questions first , Lay a good foundation and further brush algorithm problems , In this way, first of all, the basic grammar and common API There is absolutely no problem , It will definitely get twice the result with half the effort when brushing algorithm problems later !
This column will take you from basic grammar to advanced algorithms , Keep practicing step by step , Join the question brushing plan and come on !
Here I recommend Cattle from If you are confident in the basic grammar of the corresponding language, you can also brush algorithm problems , Here, the difficulty classification of algorithm problems on niuke.com is also great , There are introductory questions , Interview must brush questions , Interview high-frequency questions and so on . If the foundation is poor, then don't worry , Cattle from There are also basic grammar questions above to help you better learn the basics .
In order to make it convenient to brush the questions, I put the link of Niuke directly below , You can click the blue font to jump and brush the questions directly !
Portal : Brush the entry

This column will take you from basic grammar to advanced algorithms , Keep practicing step by step , Join the question brushing plan and come on !
JAVA5 Calculate the mall discount 【 Branch 】
subject :
Answer key :
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int price = console.nextInt();
int cost = 0;
//write your code here......
if(price>=5000){
cost = (int)(price*0.6);
}else if(price>=2000){
cost = (int)(price*0.7);
}else if(price>=500){
cost = (int)(price*0.8);
}else if(price>=100){
cost = (int)(price*0.9);
}else{
cost = (int)price;
}
System.out.println(cost);
}
}
JAVA6 Judge body mass index 【 Branch 】
subject :
Answer key :
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double height = scanner.nextDouble();
double weight = scanner.nextDouble();
//write your code here......
double log = weight/(height*height);
if(log<18.5){
System.out.println(" Thin ");
}else if(log>=18.5 && log<20.9){
System.out.println(" slim ");
}else if(log>=20.9 && log<24.9){
System.out.println(" Moderate ");
}else{
System.out.println(" Overweight ");
}
}
}
JAVA7 Judge the grades of students 【 Branch 】
subject :
Answer key :
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String grade =scanner.next();
//write your code here......
if(grade.equals("A"))// This question mainly examines == and equals The difference between , If you use ==, This will return to false
//== Are the addresses compared equal , Or whether the basic types are equal ; and grade yes new Coming out , It's an address
// Used to point to new Out object , So it belongs to the reference type
// about String class ,equals It's rewritten , Compare the content, not the address
System.out.println(" good ");
else if(grade.equals("B"))
System.out.println(" good ");
else if(grade.equals("C"))
System.out.println(" pass ");
else if(grade.equals("D"))
System.out.println(" fail, ");
else
System.out.println(" Unknown level ");
}
}
JAVA8 Mailbox validation 【 Branch 】
subject :
Answer key :
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String str = scanner.next();
String emailMatcher="[a-zA-Z0-9][email protected][a-zA-Z0-9]+\\.[a-zA-Z0-9]+";
// utilize matches() Method for regular matching , If the legitimate , The output " The email format is legal ", Otherwise output " The email format is illegal "
if(str.matches(emailMatcher)){
System.out.print(" The email format is legal ");
}else{
System.out.print(" The email format is illegal ");
}
}
}
Regular expression related knowledge points :
// Modifier + Indicates that at least one of the characters is matched
// Modifier ? Indicates that zero or one of the characters can be matched
//A-z Action is equal to the a-zA-Z
// \d Match the Numbers 0-9
// \D Match not 0-9
// \w Match the letter 、 Numbers 、 Underline , Except for special characters and spaces
// {n,m} Match at least n Time , at most m Time
// ^ Flag indicating the beginning of string matching
// For more regular expression matching, see :https://www.runoob.com/java/java-regular-expressions.html
Conclusion
In order to make it convenient to brush questions, I put the link of the website directly below , You can click the blue font to jump and brush the questions directly !
Portal : Brush Title artifact
Brush the question , Everyone must be serious , Don't slack off !
Accumulate over a long period , Fang Chengda !
边栏推荐
猜你喜欢

BUUCTF-RSA
![[unity] mapping 2D coordinates to ID](/img/e8/e6e56ba63dd56009bfabe647f2e3ed.png)
[unity] mapping 2D coordinates to ID
![[Development Tutorial 9] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - heart rate monitoring](/img/cc/91ec9f2c2cd5d5bddd157e61191772.png)
[Development Tutorial 9] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - heart rate monitoring

千万播放竟有通用公式?B站被小看的爆款机会!
![[C language] string reverse order (recursive implementation)](/img/a1/9e603321d364c7f457116bd9e462aa.png)
[C language] string reverse order (recursive implementation)

Notes on Shangpin project in shangsilicon Valley (I)

正值三伏天我却被吓出了冷汗:驾驶安全隐患离我们有多远?

Realization of gobang man-machine combat

Shell programming specifications and variables

Posture recognition and simple behavior recognition based on mediapipe
随机推荐
New media content output method - short video
JS ATM output
Reduce error demonstration
北欧岗位制博士申请有多难?
C# 事件相关的练习代码。
【zer0pts CTF 2022】 Anti-Fermat
[NPUCTF2020]EzRSA
7月第3周榜单丨飞瓜数据B站UP主排行榜发布!
R语言R原生plot函数和lines函数的主要参数说明、解析(type、pch、cex、lty、lwd、col、xlab、ylab)
(12) 51 Single Chip Microcomputer -- use DS18B20 to measure the outdoor temperature in Gongjiang West
[C language] string reverse order (recursive implementation)
Legendary Internet Setup tutorial with graphic explanation - GOM engine
The interviewer asked the thread safe list, and I'm not afraid after reading it!
[Development Tutorial 9] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - heart rate monitoring
BUUCTF-Baby RSA
Decrypt the secret of 90% reduction in oom crash~
Realization of gobang man-machine combat
【开发教程9】疯壳·开源蓝牙心率防水运动手环-心率监测
2022 latest Tiktok live broadcast monitoring full set of monitoring (V) product details monitoring
How to use C WinForm to copy files and display progress