王柳 发表于 2024-5-17 22:07:47

关于pta三次作业的总结

oop三次pta总结

前言

在这学期的java课程学习当中,我已经体会到了java这门语言的重要性了,就从这三次pta题目的计划与思路来说吧(还真的有点小难),特别是每一期pta的最后一题......
《答题判题步伐》,这道题目依次迭代,难度依次上升(如果没有计划好,基本是寄了),题目不多看几遍细节是真的不能把握,如果细节忽略了,那就要付出几倍的时间和
去修正了。(别问我怎么知道的)
这道题目涵盖正则表达式,类的计划,等知识点。从复杂到更复杂,时间泯灭的越来越多,(一个测试点一天)
接下来一题一题来分析看看吧,也总结一下本身的代码计划错误
 

计划与分析

题目1:

计划实现答题步伐,模仿一个小型的测试,要求输入题目信息和答题信息,根据输入题目信息中的标准答案判断答题的结果。
输入格式:
步伐输入信息分三部分:

1、题目数量
   格式:整数数值,若超过1位最高位不能为0,
   样例:34
2、题目内容
   一行为一道题,可以输入多行数据。
   格式:"#N:"+题号+" "+"#Q:"+题目内容+" "#A:"+标准答案
格式约束:题目的输入顺序与题号不相干,不肯定按题号顺序从小到大输入。
   样例:#N:1 #Q:1+1= #A:2
         #N:2 #Q:2+2= #A:4
3、答题信息
   答题信息按行输入,每一行为一组答案,每组答案包含第2部分所有题目的解题答案,答案的顺序号与题目题号相对应。
   格式:"#A:"+答案内容
   格式约束:答案数量与第2部分题目的数量相同,答案之间以英文空格分隔。
   样例:#A:2 #A:78
      2是题号为1的题目的答案
      78是题号为2的题目的答案<br>   答题信息以一行"end"标志结束,"end"之后的信息忽略。
输特别式:
1、题目数量
   格式:整数数值,若超过1位最高位不能为0,
   样例:34
2、答题信息
   一行为一道题的答题信息,根据题目的数量输出多行数据。
   格式:题目内容+" ~"+答案
   样例:1+1=~2
          2+2= ~4
3、判题信息
   判题信息为一行数据,一条答题记录每个答案的判断结果,答案的先后顺序与题目题号相对应。
   格式:判题结果+" "+判题结果
   格式约束:
   1、判题结果输出只能是true或者false,
   2、判题信息的顺序与输入答题信息中的顺序相同<br>   样例:true false true
import java.util.Scanner;public class Main {    public static void main(String[] args) {      Scanner sc = new Scanner(System.in);      int number;      number = sc.nextInt();      Answerpaper answerpaper[] = new Answerpaper;      int[] num = new int;      String str;      sc.nextLine();      String[][] Str = new String[];      for (int i = 1; iQuestionSum) {                QuestionSum = splitinput.getQuestionNum();            } else {                QuestionSum++;            }            question.setQuestion(QuestionSum, splitinput.getQuestionNum(), splitinput.getQuestion(), splitinput.getStandardAnswer());      }      for (int i = 1; i < Paper.length; i++) {            splitinput.setInput(Paper);            splitinput.splitPaper();            if (splitinput.getPaperNum() > PaperSum) {                PaperSum = splitinput.getPaperNum();            } else {                PaperSum++;            }            scoresumjudge.setScore(PaperSum, splitinput.getPaperNum(), splitinput.getPaperQuestionNum(), splitinput.getPaperQuestionMark());            answerquestion.setPaper(PaperSum, splitinput.getPaperNum());            answerquestion.getPaper().setPaper(splitinput.getPaperQuestionSum(), splitinput.getPaperQuestionNum(), splitinput.getPaperQuestionMark(), question);      }      scoresumjudge.printResult();      for (int i = 1; i < StudentId.length; i++) {            splitinput.setInput(StudentId);            splitinput.splitStudentId();            studentId.setStudentId(splitinput.getStudentId());            studentId.setStudentName(splitinput.getStudentName());      }      for (int i = 1; i < Deleteinformation.length; i++) {            splitinput.setInput(Deleteinformation);            splitinput.splitDeleteinformation();            delete.setDeleteNum(splitinput.getDeleteNum());      }      for (int i = 1; i < AnswerPaper.length; i++) {            splitinput.setInput(AnswerPaper);            splitinput.splitAnswer();            if (splitinput.getAnswerPaperNum() > AnswerSum) {                AnswerSum = splitinput.getAnswerPaperNum();            } else {                AnswerSum++;            }            answerquestion.setAnswerPaper(AnswerSum, splitinput.getAnswerPaperNum());            answerquestion.getAnswerPaper().setAnswerPaper(splitinput.getAnswer(), splitinput.getAnswerNum(), splitinput.getAnswerStudentName(), splitinput.getAnswerPaperNum());            if (answerquestion.getPaper().length == 1) {                System.out.println("The test paper number does not exist");                continue;            }            for (int k = 1; kquestion.getStandardAnswer().length - 1) {            System.out.println("non-existent question~0");            a = 0;      } else if (question.getStandardAnswer().getPaperQuestionNum().getAnswerNum()]].equals("laji1")) {            System.out.println("non-existent question~0");            a = 0;      } else if (question.getStandardAnswer().getPaperQuestionNum().getAnswerNum()]].equals("laji")) {            System.out.println("the question " + answerQuestion.getPaper().getPaperQuestionNum().getAnswerNum()] + " invalid~0");            a = 0;      } else {            if (answerQuestion.getAnswerPaper().getAnswer().equals(question.getStandardAnswer().getPaperQuestionNum().getAnswerNum()]])) {                System.out.println(question.getQuestion().getPaperQuestionNum().getAnswerNum()]] + "~" + answerQuestion.getAnswerPaper().getAnswer() + "~true");                mark += answerQuestion.getPaper().getPaperQuestionMark().getAnswerNum()];                a = answerQuestion.getPaper().getPaperQuestionMark().getAnswerNum()];            } else {                System.out.println(question.getQuestion().getPaperQuestionNum().getAnswerNum()]] + "~" + answerQuestion.getAnswerPaper().getAnswer() + "~false");                a = 0;            }      }      a.getAnswer().length + 199] += mark;      return a;    }    public void JudgeAnswer() {      int mark = 0;      int c[] = new int.getAnswer().length + 200];      int a[] = new int.getAnswer().length + 200];      for (int i = 1; i < delete.getDeleteNum().length; i++) {            if (delete.getDeleteNum() < question.getStandardAnswer().length)                question.getStandardAnswer()] = "laji";      }      int b = answerQuestion.getPaper().getPaperQuestionNum().length;//answerQuestion.getAnswerPaper().getAnswer().length;      answerQuestion.getAnswerPaper().bubble();      for (int j = 1; j < answerQuestion.getPaper().getPaperQuestionNum().length; j++) {            for (int i = 1; i < answerQuestion.getAnswerPaper().getAnswer().length; i++) {//临时尝试一下,可能答卷的答案不按套路出牌                if (answerQuestion.getAnswerPaper().getAnswerNum() == j) {                  a = this.printResult(i, mark, a, j);                  break;                }                if (i == answerQuestion.getAnswerPaper().getAnswer().length - 1) {                  a = 0;                  System.out.println("answer is null");                }            }      }      if (answerQuestion.getAnswerPaper().getAnswer().length == 1) {            for (int i = 1; i < answerQuestion.getPaper().getPaperQuestionNum().length; i++) {                System.out.println("answer is null");            }      }      for (int i = 1; i < studentId.getStudentId().length; i++) {            if (answerQuestion.getAnswerPaper().getAnswerStudent().equals(studentId.getStudentId())) {                System.out.printf("%s %s: ", studentId.getStudentId(), studentId.getStudentName());                break;            }            if (i == studentId.getStudentId().length - 1) {                System.out.println(answerQuestion.getAnswerPaper().getAnswerStudent() + " not found");                return;            }      }      for (int i = 1; i < b; i++) {            if (i != b - 1)                System.out.printf("%d ", a);            else                System.out.printf("%d", a);      }      System.out.println("~" + a.getAnswer().length + 199]);    }}class Judge {    private String[] input;    private int length;    private int k = 1;    private int m = 1;    public Judge() {    }    public Judge(String[] input, int length) {      this.input = new String;      for (int i = 1; i < length; i++) {            this.input = input;      }    }    public void setInput(String[] input, int length) {      this.input = new String;      for (int i = 1; i < length; i++) {            this.input = input;      }    }    public String[] JudgeQuestion() {      for (int i = 1; i
页: [1]
查看完整版本: 关于pta三次作业的总结