第二小题我不知道哪错了,

package 十二周作业;

import java.util.Scanner;
import java.io.PrintStream;

public class Main {
    public static void printMarks(String str) {
        int pos=0;
        char a[]=str.toCharArray();
        for (int i=0;i<a.length;i++) {
            if(a[i]==',') {
                pos=i+1;
            }
        }
        String marksStr;
        marksStr=str.substring(pos);
        System.out.println(marksStr);
    }
    public static void main(String[] args) throws java.io.UnsupportedEncodingException {
        PrintStream ps = new PrintStream(System.out, true, "UTF-8");
        Scanner in = new Scanner(System.in, "UTF-8");

        String str;
        str = in.next();
        printMarks(str);
        
    }
}

2 条评论

  • 1