前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Java入门 - 详细的 Java 语法编程练习

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

作者头像
Lokinli
发布2023-03-09 16:41:09
3320
发布2023-03-09 16:41:09
举报
文章被收录于专栏:以终为始以终为始

转载请注明出处: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("100\r\n" + 
				"A\r\n" + 
				"3.140000 ");
	}
}

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

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

public class Main {

	public static void main(String[] args) {
		System.out.println("#\r\n" + 
				"##\r\n" + 
				"###\r\n" + 
				"####\r\n" + 
				"#####\r\n" + 
				"######");
	}
}

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("******************************\r\n" + 
				"\r\n" + 
				"          Very good!\r\n" + 
				"\r\n" + 
				"******************************");
	}
}

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

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

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

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("%.2f\n",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 %.2f\n", 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("%.2f\n", C);
	}
}

火车(SDUT 2396)

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-07-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • C语言实验——圆柱体计算(SDUT 1207)
  • C语言实验——温度转换(SDUT 1208)
  • 火车(SDUT 2396)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档