参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); print(input()); } public static String[] input(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); // 吸收空格 sc.nextLine(); String[] st = new String[n]; for (int i = 0; i < n; i++) { String str = sc.nextLine(); st[i] = str.replaceAll(" ",",");; } return st; } public static void print(String[] st){ for (int i = 0; i < st.length; i++) { System.out.println(st[i]); } } }
0.0分
2 人评分
C语言训练-字符串正反连接 (C语言代码)浏览:710 |
C二级辅导-公约公倍 (C语言代码)浏览:2129 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:650 |
简单的a+b (C语言代码)浏览:563 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)浏览:548 |
【亲和数】 (C语言代码)浏览:507 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:781 |
简单的a+b (C语言代码)浏览:612 |
WU-蓝桥杯算法提高VIP-交换Easy (C++代码)浏览:1123 |
C语言训练-列出最简真分数序列* (C语言代码)浏览:638 |