在线编程题刷题训练
所有答案
scancer函数的用法
输入输出总结top!!!!
java如何调用函数(方法)
java刷acm的各种输入输出
vscode配置java环境
- 子函数的调用,直接定义一个static子函数调用就可以
HW
编程刷题网站
HW ACM 从单向链表中删除指定值的节点
String c=sc.nextLine();c=c.toLowerCase();String s=str.toUpperCase();Character.isUpperCase(s.charAt(i))String.valueOf() / String c=new String(chars);
char[] chars=new char[len];for(int i=0;i<len;i++){chars[i]=s.charAt(i);}
[^a-zA-Z]
map.size()
builder.reverse().toString().trim();String[] s1 = s.split(" ");String[] s1 = s.split("[^a-zA-Z]");
mul2[i][j]=Integer.parseInt(strs[j]);
Integer.parseInt(s)//字符串转为数字
- 输出矩阵
print将它的参数显示在命令窗口,并将输出光标定位在所显示的最后一个字符之后。
println 将它的参数显示在命令窗口,并在结尾加上换行符,将输出光标定位在下一行的开始。for(int i=0;i<a;i++){for(int j=0;j<c;j++){System.out.print(result[i][j]+" ");
// System.out.println(' ');}System.out.println ();}
判断字母大小写
if(str1.charAt(i)==str2.charAt(i)){i++;}else if(str1.charAt(i)<str2.charAt(i)){return true;//str1更小 }
16进制的表示(0X)
以及字母转化为数字???
Character.isLetter
Character.isDigit
if(str.charAt(i)-'0'>=0&&str.charAt(i)-'0'<10){sum=sum*16+str.charAt(i)-'0';}else if(str.charAt(i)>='A'&&str.charAt(i)<='F'){sum=sum*16+(str.charAt(i)-'A'+10);}
判断一个字符串是否是字母
if (((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) {return true;
1、a+b
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);while(sc.hasNext()){int a = sc.nextInt(); //读取到第一个结束标志符号作为结束(空格回车 tab键)int b = sc.nextInt();System.out.println(a + b);}}}
2、a+b(2)
import java.util.*;
public class Main {public static void main (String[] args) {Scanner in = new Scanner(System.in);int len = in.nextInt();for(int i=0;i<len;i++){System.out.println(in.nextInt() + in.nextInt());}}
}
3、a+b(3)
import java.util.Scanner;
public class Main{public static void main(String[] args){Scanner scanner = new Scanner(System.in);while(scanner.hasNext()){int a = scanner.nextInt();int b = scanner.nextInt();int c = a + b;if(a == 0 && b == 0){break;}else{System.out.println(c);}}}}
4、a+b(4)
import java.util.Scanner;public class Main{public static void main(String[] args){Scanner in = new Scanner(System.in);while(in.hasNextLine()){int n = in.nextInt();if (n == 0){return;}int[] temp = new int[n];int res = 0;for (int i = 0; i < n; i++){temp[i] = in.nextInt();res += temp[i];}System.out.println(res);}}
}
5、a+b(5)
import java.util.*;
public class Main{public static void main(String[] args){Scanner sc = new Scanner(System.in);int a = sc.nextInt();for(int i=0;i<a;i++){int b=sc.nextInt();int sum = 0;for(int j=0;j<b;j++){sum+=sc.nextInt();}System.out.println(sum);}}
}
6、a+b(6)
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);while (sc.hasNext()){int n = sc.nextInt();int[] temp = new int[n];int res = 0;for (int i = 0; i < n; i++){temp[i] = sc.nextInt();res += temp[i];}System.out.println(res);}}
}
7、a+b(7)
import java.util.*;
public class Main{public static void main(String[] args){Scanner sc=new Scanner(System.in);while(sc.hasNext()){//把输入的字符串以“(引号里的内容)”为条件分割成一个String数组String[] s=sc.nextLine().split(" ");int sum=0;for(int i=0;i<s.length;i++){//Integer.parseInt(s)的作用就是把字符串s解析成有符号的int基本类型sum=sum+Integer.parseInt(s[i]);}System.out.println(sum);}}
}
//
字符串排序(1)
import java.util.Arrays;
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String n = sc.nextLine();String str = sc.nextLine();String[] numStr = str.split(" ");Arrays.sort(numStr);for (int i = 0; i < numStr.length; i++){System.out.print(numStr[i]+" ");}}
}
字符串排序(2)
import java.util.*;
public class Main{public static void main(String[] args){Scanner sc = new Scanner(System.in);while (sc.hasNext()){String s = sc.nextLine();String[] str = s.split(" ");Arrays.sort(str);for (int i = 0; i < str.length; i++){System.out.print(str[i] + " ");}System.out.println();}}
}
字符串排序(3)
import java.util.*;public class Main{public static void main(String[] args){Scanner sc = new Scanner(System.in);while(sc.hasNextLine()){String[] s = sc.nextLine().split(",");Arrays.sort(s);for(int j = 0;j < s.length - 1;j++){System.out.print(s[j] + ",");}System.out.println(s[s.length - 1]);} }
}
京东题目
import java.util.Scanner;
import java.util.*;
public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);while(sc.hasNext()){int n = sc.nextInt(); //读取到第一个结束标志符号作为结束(空格回车 tab键)String s = sc.nextLine();String[] numStr = s.split(" ");int k=sub(n,numStr);System.out.println(k);//System.out.println(a + b);}}public static int sub(int n,String[] s) {int sum=0;return sum;}}