还是函数第二题,我提交全错了

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

public class Main {
        public static void printMarks(String str)
    {
        
        int pos;
        pos = str.indexOf(',');
        String marksStr;
        System.out.println();   
    }
    
    
    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=in.next();
        int a =str.indexOf(',');
        printMarks(str);
        System.out.println(str.substring(a+1));
    }
    
}

4 条评论

  • @ 2019-05-27 21:39:09

    你这个更新之后的代码还有错吗?

  • @ 2019-05-27 21:12:43
    import java.util.Scanner;
    import java.io.PrintStream;
    
    public class Main {
          public static void printMarks(String str)
        {
            int pos =str.indexOf(',');
            System.out.println(str.substring(pos+1)); 
        }
        
        
        
        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=in.next();
            printMarks(str);
        }
        
    }
    

    好了,更新了上面的代码

  • @ 2019-05-27 17:14:02

    不太明白你所说的“上面的函数”指的是什么。哪里?第几行?哪个函数?

    不过,无论你是哪种意思,我都建议你自己先改改代码试一试哈。

  • @ 2019-05-26 22:13:43

    你多打印了一个空行

    • @ 2019-05-27 10:47:28

      那上面的函数还有用吗?

  • 1