当前位置:   article > 正文

JAVA入门

import java.util.scanner;class throwexception{ static void f(int n,int m

转载请注明出处:https://blog.csdn.net/Mercury_Lc/article/details/82656607

(SDUT专题练习)

A-  A+B Problem(SDUT 1000)

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int a, b;
  6. a = sc.nextInt();
  7. b = sc.nextInt();
  8. System.out.println(a+b);
  9. }
  10. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int a, b;
  6. while (sc.hasNext()) {
  7. a = sc.nextInt();
  8. b = sc.nextInt();
  9. System.out.println(a + b);
  10. }
  11. }
  12. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int a, b, n;
  6. while (sc.hasNext()) {
  7. n = sc.nextInt();
  8. for (int i = 0; i < n; i++) {
  9. a = sc.nextInt();
  10. b = sc.nextInt();
  11. System.out.println(a + b);
  12. }
  13. }
  14. }
  15. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int a, b;
  6. while (sc.hasNext()) {
  7. a = sc.nextInt();
  8. b = sc.nextInt();
  9. if (a == 0 && b == 0)
  10. break;
  11. System.out.println(a + b);
  12. }
  13. }
  14. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner reader = new Scanner(System.in);
  5. int n,x,sum;
  6. while(reader.hasNext()){
  7. n = reader.nextInt();
  8. if(n == 0)break;
  9. sum = 0;
  10. for(int i = 0; i < n; i ++){
  11. x =reader.nextInt();
  12. sum += x;
  13. }
  14. System.out.println(sum);
  15. }
  16. }
  17. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int m, sum, x, n;
  6. while (sc.hasNext()) {
  7. n = sc.nextInt();
  8. sum = 0;
  9. for (int k = 0; k < n; k++) {
  10. m = sc.nextInt();
  11. sum = 0;
  12. for (int i = 0; i < m; i++) {
  13. x = sc.nextInt();
  14. sum += x;
  15. }
  16. System.out.println(sum);
  17. }
  18. }
  19. }
  20. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int sum, x, n;
  6. while (sc.hasNext()) {
  7. n = sc.nextInt();
  8. sum = 0;
  9. for (int i = 0; i < n; i++) {
  10. x = sc.nextInt();
  11. sum += x;
  12. }
  13. System.out.println(sum);
  14. }
  15. }
  16. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int a, b;
  6. while (sc.hasNext()) {
  7. a = sc.nextInt();
  8. b = sc.nextInt();
  9. System.out.println(a + b);
  10. System.out.println("");
  11. }
  12. }
  13. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int m, sum, x, n;
  6. while (sc.hasNext()) {
  7. n = sc.nextInt();
  8. sum = 0;
  9. for (int k = 0; k < n; k++) {
  10. m = sc.nextInt();
  11. sum = 0;
  12. for (int i = 0; i < m; i++) {
  13. x = sc.nextInt();
  14. sum += x;
  15. }
  16. System.out.println(sum);
  17. System.out.println("");
  18. }
  19. }
  20. }
  21. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. System.out.println("Hello World!");
  5. }
  6. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. System.out.println("100\r\n" +
  5. "A\r\n" +
  6. "3.140000 ");
  7. }
  8. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. System.out.println("#\r\n" +
  5. "##\r\n" +
  6. "###\r\n" +
  7. "####\r\n" +
  8. "#####\r\n" +
  9. "######");
  10. }
  11. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. char c;
  5. String s;
  6. Scanner sc = new Scanner(System.in);
  7. s = sc.next();
  8. c = s.charAt(0);
  9. System.out.println(c);
  10. }
  11. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int a, b;
  6. a = sc.nextInt();
  7. b = sc.nextInt();
  8. System.out.println(a+b);
  9. }
  10. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int a, b, c;
  6. a = sc.nextInt();
  7. b = sc.nextInt();
  8. c = a;
  9. a = b;
  10. b = c;
  11. System.out.println(a + " " + b);
  12. }
  13. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. String s;
  6. s = sc.nextLine();
  7. System.out.println(s.toUpperCase());
  8. }
  9. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. System.out.println("This is a C program.");
  5. }
  6. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. System.out.println("sum is 579");
  5. }
  6. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. System.out.println("******************************\r\n" +
  5. "\r\n" +
  6. " Very good!\r\n" +
  7. "\r\n" +
  8. "******************************");
  9. }
  10. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. System.out.println("*****\r\n" +
  5. "*\r\n" +
  6. "*\r\n" +
  7. "*\r\n" +
  8. "*****");
  9. }
  10. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int a,b,c;
  6. a = sc.nextInt(); b = sc.nextInt();c = sc.nextInt();
  7. double ave = (a + b + c) / 3.0;
  8. System.out.print(a+b+c+" "+ (a*b*c)+" ");
  9. System.out.printf("%.2f\n",ave);
  10. }
  11. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int n, a, b, c, m;
  6. n = sc.nextInt();
  7. a = n / 100;
  8. b = n / 10 % 10;
  9. c = n % 100 % 10;
  10. m = a + b * 10 + c * 100;
  11. System.out.println(m);
  12. }
  13. }

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

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int n, m, k;
  6. n = sc.nextInt();
  7. n = n * 10;
  8. m = n / 3;
  9. k = n % 3;
  10. System.out.println(m + " " + k);
  11. }
  12. }

C语言实验——圆柱体计算(SDUT 1207)

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. final double P = 3.1415926;
  6. double r, h;
  7. double ans1, ans2, ans3, ans4;
  8. r = sc.nextDouble();
  9. h = sc.nextDouble();
  10. ans1 = 2 * P * r;
  11. ans2 = P * r * r;
  12. ans3 = 2 * P * r * h;
  13. ans4 = ans2 * h;
  14. System.out.printf("%.2f %.2f %.2f %.2f\n", ans1, ans2, ans3, ans4);
  15. }
  16. }

C语言实验——温度转换(SDUT 1208)

  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. double F, C;
  6. F = sc.nextDouble();
  7. C = 5 * (F - 32) / 9;
  8. System.out.printf("%.2f\n", C);
  9. }
  10. }

火车(SDUT 2396)

 

转载于:https://www.cnblogs.com/lcchy/p/10139519.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/207376?site
推荐阅读
相关标签
  

闽ICP备14008679号