题解 | #按照格式输入并交换输出#

按照格式输入并交换输出

https://www.nowcoder.com/practice/95eb723a3e854376a7eb6d116cc7d875

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

     

        String str = in.nextLine();

//当次分割

        // String strs[] = str.split(",");

        // int a1 = Integer.parseInt(strs[0].split("=")[1]);

        // int b1 = Integer.parseInt(strs[1].split("=")[1]);

        // System.out.println(strs[0].split("=")[0] + "="+b1+","+strs[1].split("=")[0]+"="+a1);

//分割多次

        String strs[] = str.split("[=,]");

        System.out.println("a="+strs[3]+",b="+strs[1]);

    }

}

全部评论

相关推荐

06-07 19:59
门头沟学院 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务