Java入门 - 详细的 Java 语法编程练习

2023-03-09 16:41:09 浏览数 (1)

转载请注明出处:JAVA入门_Mercury_Lc的博客-CSDN博客 (SDUT专题练习)

详细的 Java 语法编程练习

A-  A B Problem(SDUT 1000)

代码语言:javascript复制
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);
	} 
}

B-A B for Input-Output Practice (I)(SDUT 1010)

代码语言:javascript复制
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);		
		}
	}
}

C-A B for Input-Output Practice (II)(SDUT 1011)

代码语言:javascript复制
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);
			}
		}
	}
}

D-A B for Input-Output Practice (III)(SDUT 1012)

代码语言:javascript复制
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);
		}
	}
}

E-A B for Input-Output Practice (IV)(SDUT 1013)

代码语言:javascript复制
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);
		}
	}
}

F-A B for Input-Output Practice (V)(SDUT 1014)

代码语言:javascript复制
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);
			}
		}
	}
}

G-A B for Input-Output Practice (VI)(SDUT 1015)

代码语言:javascript复制
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);
		}
	}
}

H-A B for Input-Output Practice (VII)(SDUT  1016)

代码语言:javascript复制
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("");
		}
	}
}

I-A B for Input-Output Practice(SDUT 1017)

代码语言:javascript复制
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("");
			}
		}
	}
}

J-C语言实验——Hello World!(printf练习)(SDUT 1110)

代码语言:javascript复制
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println("Hello World!");
	}
}

K-C语言实验——格式化输出(常量练习)(SDUT 1111)

代码语言:javascript复制
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println("100rn"   
				"Arn"   
				"3.140000 ");
	}
}

L-C语言实验——图形输出(字符常量练习)(SDUT  1112)

代码语言:javascript复制
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println("#rn"   
				"##rn"   
				"###rn"   
				"####rn"   
				"#####rn"   
				"######");
	}
}

M-C语言实验——单个字符输入和输出(顺序结构)(SDUT 1113)

代码语言:javascript复制
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);
	}
}

N-C语言实验——计算A B(顺序结构)(SDUT 1114)

代码语言:javascript复制
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);
	} 
}

O-C语言实验——交换两个整数的值(顺序结构)(SDUT 1115)

代码语言:javascript复制
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);
	}
}

P-C语言实验——转换字母(顺序结构)(SDUT 1116)

代码语言:javascript复制
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());
	}
}

Q-C语言实验——输出字符串(SDUT 1151)

代码语言:javascript复制
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		System.out.println("This is a C program.");
	}
}

R-C语言实验——求两个整数之和(SDUT 1152)

代码语言:javascript复制
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		System.out.println("sum is 579");
	}
}

S-C语言实验——打印图形(SDUT 1155)

代码语言:javascript复制
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		System.out.println("******************************rn"   
				"rn"   
				"          Very good!rn"   
				"rn"   
				"******************************");
	}
}

T-C语言实验——用*号输出字母C的图案(SDUT 1156)

代码语言:javascript复制
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		System.out.println("*****rn"   
				"*rn"   
				"*rn"   
				"*rn"   
				"*****");
	}
}

U-C语言实验——三个整数和、积与平均值(SDUT 1167)

代码语言:javascript复制
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);
	}
}

V-C语言实验——逆置正整数(SDUT 1189)

代码语言:javascript复制
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);
	}
}

W-C语言实验——买糖果(SDUT 1203)

代码语言:javascript复制
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);
	}
}

火车(SDUT 2396)

0 人点赞