java 华为牛客网编程题_牛客编程题(十一)

//https://www.nowcoder.com/practice/1e5655d7c7be4566b386eb925afcb206?tpId=185&tags=&title=&diffculty=0&judgeStatus=0&rp=1

import java.util.Arrays;

import java.util.Scanner;

public class Main4 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

String s = sc.next();

System.out.println(change(s)); }

public static String change(String s) { char[] c = s.toCharArray(); for(int i=0;i

}1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

//https://www.nowcoder.com/practice/0ae4a12ab0a048ee900d1536a6e98315?tpId=125&&tqId=33732&rp=1&ru=/ta/exam-xiaomi&qru=/ta/exam-xiaomi/question-ranking

import java.util.Scanner;

public class Main5 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

String xx = sc.nextLine();

String[] str = xx.split(" ");

for(int i=0;i

}

for(int i=0;i

}

} }1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

//https://www.nowcoder.com/practice/45083499b8c5404fb1db44c6ea4f170a?tpId=122&&tqId=33702&rp=1&ru=/ta/exam-wangyi&qru=/ta/exam-wangyi/question-ranking

import java.util.Scanner;

public class Main6 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

String str = sc.nextLine(); char[] c= str.toCharArray();

for(int i=0;i

}

String res ="";

for(int i=0;i

}

res=String.valueOf(c[0]).concat(res);

System.out.println(res);

}

}1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

//https://www.nowcoder.com/practice/b178fcef3ed4448c99d7c0297312212d?tpId=125&tags=&title=&diffculty=0&judgeStatus=0&rp=1

import java.util.Scanner;

public class Main7 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

System.out.println(climbStairs(n));

}

public static int climbStairs(int n) {

if(n==1) { return 1;

}

if(n==2) { return 2;

}

if(n>=3) { return climbStairs(n-1)+climbStairs(n-2);

}

else return 0;

}

}1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

//https://www.nowcoder.com/practice/e90351c561ff40a4b2bbf067bbbb5f31?tpId=128&&tqId=33791&rp=1&ru=/ta/exam-meituan&qru=/ta/exam-meituan/question-ranking

import java.util.Scanner;

public class Main8 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while (sc.hasNext()) { int n = sc.nextInt(); int m = sc.nextInt(); if(n

}

}1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

//https://www.nowcoder.com/practice/e297fdd8e9f543059b0b5f05f3a7f3b2?tpId=188&&tqId=36729&rp=1&ru=/ta/job-code-high-week&qru=/ta/job-code-high-week/question-ranking

import java.util.Scanner;

public class Main9 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

String str = sc.next();

System.out.println(judge(str)); }

public static boolean judge (String str) { // write code here

if(str.equals("")) return true;

str = str.toLowerCase();

int start = 0;

int end = str.length()-1;

while(start='a'&&str.charAt(start)<='z')||str.charAt(start)<='9'&&str.charAt(start)>='0') { start++; } while(!(str.charAt(end)>='a'&&str.charAt(end)<='z')||str.charAt(end)<='9'&&str.charAt(end)>='0') { end--; } if(str.charAt(start)!=str.charAt(end)) return false; start++; end--;

}

return true; }

}1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

//https://www.nowcoder.com/practice/8cc4f31432724b1f88201f7b721aa391?tpId=117&&tqId=35069&rp=1&ru=/ta/job-code-high&qru=/ta/job-code-high/question-ranking

import java.util.Arrays;

public class Main0 {

public static void main(String[] args) { int[]arr = {1,2,3,4};

System.out.println(minNumberdisappered(arr)); }

public static int minNumberdisappered (int[] arr) { int res = 1; Arrays.sort(arr); while(true) { for(int i=0;i

}1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

//https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9?tpId=37&&tqId=21246&rp=1&ru=/ta/huawei&qru=/ta/huawei/question-ranking

import java.util.Scanner;

public class Main1 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while (sc.hasNext()) { String str = sc.nextLine(); int min = 100; char[] c = str.toCharArray(); StringBuilder ss = new StringBuilder(); int[] sum = new int[str.length()]; for (int i = 0; i < c.length; i++) {// 找到每个字符出现的次数 for (int j = 0; j < str.length(); j++) { if (c[i] == str.charAt(j)) { sum[i]++; } } } for (int i = 0; i < sum.length; i++) { if (sum[i] < min) { min = sum[i]; } } for (int i = 0; i < str.length(); i++) { if (sum[i] != min) { ss.append(str.charAt(i)); } } System.out.println(ss);

}

}

}1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

文章来源: blog.csdn.net,作者:一只可爱的小狐狸,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq_45874107/article/details/113428131

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值