转载请注明出处:JAVA入门_Mercury_Lc的博客-CSDN博客 (SDUT专题练习)
详细的 Java 语法编程练习
代码语言:javascript复制A- A B Problem(SDUT 1000)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b;
a = sc.nextInt();
b = sc.nextInt();
System.out.println(a b);
}
}
代码语言:javascript复制B-A B for Input-Output Practice (I)(SDUT 1010)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b;
while (sc.hasNext()) {
a = sc.nextInt();
b = sc.nextInt();
System.out.println(a b);
}
}
}
代码语言:javascript复制C-A B for Input-Output Practice (II)(SDUT 1011)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b, n;
while (sc.hasNext()) {
n = sc.nextInt();
for (int i = 0; i < n; i ) {
a = sc.nextInt();
b = sc.nextInt();
System.out.println(a b);
}
}
}
}
代码语言:javascript复制D-A B for Input-Output Practice (III)(SDUT 1012)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b;
while (sc.hasNext()) {
a = sc.nextInt();
b = sc.nextInt();
if (a == 0 && b == 0)
break;
System.out.println(a b);
}
}
}
代码语言:javascript复制E-A B for Input-Output Practice (IV)(SDUT 1013)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int n,x,sum;
while(reader.hasNext()){
n = reader.nextInt();
if(n == 0)break;
sum = 0;
for(int i = 0; i < n; i ){
x =reader.nextInt();
sum = x;
}
System.out.println(sum);
}
}
}
代码语言:javascript复制F-A B for Input-Output Practice (V)(SDUT 1014)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m, sum, x, n;
while (sc.hasNext()) {
n = sc.nextInt();
sum = 0;
for (int k = 0; k < n; k ) {
m = sc.nextInt();
sum = 0;
for (int i = 0; i < m; i ) {
x = sc.nextInt();
sum = x;
}
System.out.println(sum);
}
}
}
}
代码语言:javascript复制G-A B for Input-Output Practice (VI)(SDUT 1015)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum, x, n;
while (sc.hasNext()) {
n = sc.nextInt();
sum = 0;
for (int i = 0; i < n; i ) {
x = sc.nextInt();
sum = x;
}
System.out.println(sum);
}
}
}
代码语言:javascript复制H-A B for Input-Output Practice (VII)(SDUT 1016)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b;
while (sc.hasNext()) {
a = sc.nextInt();
b = sc.nextInt();
System.out.println(a b);
System.out.println("");
}
}
}
代码语言:javascript复制I-A B for Input-Output Practice(SDUT 1017)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m, sum, x, n;
while (sc.hasNext()) {
n = sc.nextInt();
sum = 0;
for (int k = 0; k < n; k ) {
m = sc.nextInt();
sum = 0;
for (int i = 0; i < m; i ) {
x = sc.nextInt();
sum = x;
}
System.out.println(sum);
System.out.println("");
}
}
}
}
代码语言:javascript复制J-C语言实验——Hello World!(printf练习)(SDUT 1110)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
代码语言:javascript复制K-C语言实验——格式化输出(常量练习)(SDUT 1111)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("100rn"
"Arn"
"3.140000 ");
}
}
代码语言:javascript复制L-C语言实验——图形输出(字符常量练习)(SDUT 1112)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("#rn"
"##rn"
"###rn"
"####rn"
"#####rn"
"######");
}
}
代码语言:javascript复制M-C语言实验——单个字符输入和输出(顺序结构)(SDUT 1113)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
char c;
String s;
Scanner sc = new Scanner(System.in);
s = sc.next();
c = s.charAt(0);
System.out.println(c);
}
}
代码语言:javascript复制N-C语言实验——计算A B(顺序结构)(SDUT 1114)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b;
a = sc.nextInt();
b = sc.nextInt();
System.out.println(a b);
}
}
代码语言:javascript复制O-C语言实验——交换两个整数的值(顺序结构)(SDUT 1115)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b, c;
a = sc.nextInt();
b = sc.nextInt();
c = a;
a = b;
b = c;
System.out.println(a " " b);
}
}
代码语言:javascript复制P-C语言实验——转换字母(顺序结构)(SDUT 1116)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s;
s = sc.nextLine();
System.out.println(s.toUpperCase());
}
}
代码语言:javascript复制Q-C语言实验——输出字符串(SDUT 1151)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("This is a C program.");
}
}
代码语言:javascript复制R-C语言实验——求两个整数之和(SDUT 1152)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("sum is 579");
}
}
代码语言:javascript复制S-C语言实验——打印图形(SDUT 1155)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("******************************rn"
"rn"
" Very good!rn"
"rn"
"******************************");
}
}
代码语言:javascript复制T-C语言实验——用*号输出字母C的图案(SDUT 1156)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("*****rn"
"*rn"
"*rn"
"*rn"
"*****");
}
}
代码语言:javascript复制U-C语言实验——三个整数和、积与平均值(SDUT 1167)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a,b,c;
a = sc.nextInt(); b = sc.nextInt();c = sc.nextInt();
double ave = (a b c) / 3.0;
System.out.print(a b c " " (a*b*c) " ");
System.out.printf("%.2fn",ave);
}
}
代码语言:javascript复制V-C语言实验——逆置正整数(SDUT 1189)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n, a, b, c, m;
n = sc.nextInt();
a = n / 100;
b = n / 10 % 10;
c = n % 100 % 10;
m = a b * 10 c * 100;
System.out.println(m);
}
}
代码语言:javascript复制W-C语言实验——买糖果(SDUT 1203)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n, m, k;
n = sc.nextInt();
n = n * 10;
m = n / 3;
k = n % 3;
System.out.println(m " " k);
}
}
C语言实验——圆柱体计算(SDUT 1207)
代码语言:javascript复制import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final double P = 3.1415926;
double r, h;
double ans1, ans2, ans3, ans4;
r = sc.nextDouble();
h = sc.nextDouble();
ans1 = 2 * P * r;
ans2 = P * r * r;
ans3 = 2 * P * r * h;
ans4 = ans2 * h;
System.out.printf("%.2f %.2f %.2f %.2fn", ans1, ans2, ans3, ans4);
}
}
C语言实验——温度转换(SDUT 1208)
代码语言:javascript复制import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double F, C;
F = sc.nextDouble();
C = 5 * (F - 32) / 9;
System.out.printf("%.2fn", C);
}
}