zoukankan      html  css  js  c++  java
  • 笔试:在线编程相关

    
    
    Java输入输出示例

    //输入一组数据并输出   Scanner sc = new Scanner(System.in);   String str=sc.nextLine();   System.out.printf("%s ",str); //输入多组数据并输出   Scanner sc = new Scanner(System.in);   String str;   while(sc.hasNextLine()){     str = sc.nextLine();     System.out.printf("%s ",str);   }


    样例
    import java.io.*;
    import java.util.*;
    class Test {
    }
    public class Main
    {
        public static void main(String args[])
        {
            Scanner cin = new Scanner(System.in);
            int a, b;
            while(cin.hasNextInt())
            {
                a = cin.nextInt();
                b = cin.nextInt();
                System.out.println(a + b);
            }
        }
    }
     
    import java.io.*;
    import java.util.*;
    
    public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            
        }
    }
    
    
    
     

    多行数据示例:

    三行:第一行为集合A和B的长度,第二行为集合A,第三行为集合B;示例:
    1 2
    1
    2 3
    import java.util.Scanner;
    
    public class Main {
    
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            while(sc.hasNext()){
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[] arrayN = new int[n];
                int[] arrayM = new int[m];
                for (int i = 0; i < n; i++) {
                    arrayN[i] = sc.nextInt();
                }
                for (int i = 0; i < n; i++) {
                    arrayM[i] = sc.nextInt();
                }
            }
    
        }
    
    }
    
    
    
     
  • 相关阅读:
    python函数对象
    生成器表达式,列表推导式
    python转换excel成py文件
    Python处理excel表
    Go基础:接口相关
    JAVA03-输入和输出
    python6-while循环
    python5-字典
    自动化8-xpath
    网络学习day1-计算机网络基础
  • 原文地址:https://www.cnblogs.com/buwenyuwu/p/6605701.html
Copyright © 2011-2022 走看看