(Java)OJ在线编程常见输入输出练习场题解汇总

题源链接: https://ac.nowcoder.com/acm/contest/5647?from=hr_test#question     


目录

1 A+B(1) ​

2 A+B(2)  

3 A+B(3)  

4 A+B(4)  

5 A+B(5) 

6 A+B(6) 

7 A+B(7) 

8 字符串排序(1)

9 字符串排序(2)

10 字符串排序(3)


1 A+B(1) 

(Java)OJ在线编程常见输入输出练习场题解汇总_第1张图片

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();
            int b = sc.nextInt();
            System.out.println(a+b);
        }
    }
}

2 A+B(2)  

(Java)OJ在线编程常见输入输出练习场题解汇总_第2张图片

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while(n>0){
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a+b);
            n--;
        }
    }
}

3 A+B(3)  

(Java)OJ在线编程常见输入输出练习场题解汇总_第3张图片

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();
            int b = sc.nextInt();
            if(a==0 & b==0) break;
            System.out.println(a+b);
        }
    }
}

4 A+B(4)  

(Java)OJ在线编程常见输入输出练习场题解汇总_第4张图片

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);        
        int len = sc.nextInt();
        while(len!=0){
            int sum = 0;
            for (int i=0;i

5 A+B(5) 

(Java)OJ在线编程常见输入输出练习场题解汇总_第5张图片

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        while(n>0){
            int sum = 0;
            String a = sc.nextLine();
            String[] as = a.split(" ");
            for(int i=1;i

6 A+B(6) 

(Java)OJ在线编程常见输入输出练习场题解汇总_第6张图片

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            int sum = 0;
            String a = sc.nextLine();
            String[] as = a.split(" ");
            for(int i=1;i

 

7 A+B(7) 

(Java)OJ在线编程常见输入输出练习场题解汇总_第7张图片

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            int sum = 0;
            String a = sc.nextLine();
            String[] as = a.split(" ");
            for(int i=0;i

 

8 字符串排序(1)

(Java)OJ在线编程常见输入输出练习场题解汇总_第8张图片

import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        while(sc.hasNextLine()){
            String a = sc.nextLine();
            String[] as = a.split(" ");
            Arrays.sort(as);
            for(int i=0;i

 

9 字符串排序(2)

(Java)OJ在线编程常见输入输出练习场题解汇总_第9张图片

import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String a = sc.nextLine();
            String[] as = a.split(" ");
            Arrays.sort(as);
            for(int i=0;i

 

10 字符串排序(3)

(Java)OJ在线编程常见输入输出练习场题解汇总_第10张图片

import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String a = sc.nextLine();
            String[] as = a.split(",");
            Arrays.sort(as);
            for(int i=0;i

 

你可能感兴趣的:(数据结构与算法,&,刷题)