关于pta三次作业的总结

王柳  金牌会员 | 2024-5-17 22:07:47 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 896|帖子 896|积分 2688

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
  1.       2是题号为1的题目的答案
  2.       78是题号为2的题目的答案<br>
复制代码
   答题信息以一行"end"标志结束,"end"之后的信息忽略。
输特别式:
1、题目数量
   格式:整数数值,若超过1位最高位不能为0,
   样例:34
2、答题信息
   一行为一道题的答题信息,根据题目的数量输出多行数据。
   格式:题目内容+" ~"+答案
   样例:1+1=~2
          2+2= ~4
3、判题信息
   判题信息为一行数据,一条答题记录每个答案的判断结果,答案的先后顺序与题目题号相对应。
   格式:判题结果+" "+判题结果
   格式约束:
  1.      1、判题结果输出只能是true或者false,
  2.      2、判题信息的顺序与输入答题信息中的顺序相同<br>
复制代码
   样例:true false true
[code]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[2 * number + 1];        int[] num = new int[number + 1];        String str;        sc.nextLine();        String[][] Str = new String[number + 2][];        for (int i = 1; i  QuestionSum) {                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()[splitinput.getPaperNum()].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()[splitinput.getAnswerPaperNum()].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; k  question.getStandardAnswer().length - 1) {            System.out.println("non-existent question~0");            a[ii] = 0;        } else if (question.getStandardAnswer()[answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum()[answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum()]].equals("laji1")) {            System.out.println("non-existent question~0");            a[ii] = 0;        } else if (question.getStandardAnswer()[answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum()[answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum()]].equals("laji")) {            System.out.println("the question " + answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum()[answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum()] + " invalid~0");            a[ii] = 0;        } else {            if (answerQuestion.getAnswerPaper()[AnswerNum].getAnswer().equals(question.getStandardAnswer()[answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum()[answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum()]])) {                System.out.println(question.getQuestion()[answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum()[answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum()]] + "~" + answerQuestion.getAnswerPaper()[AnswerNum].getAnswer() + "~true");                mark += answerQuestion.getPaper()[AnswerNum].getPaperQuestionMark()[answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum()];                a[ii] = answerQuestion.getPaper()[AnswerNum].getPaperQuestionMark()[answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum()];            } else {                System.out.println(question.getQuestion()[answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum()[answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum()]] + "~" + answerQuestion.getAnswerPaper()[AnswerNum].getAnswer() + "~false");                a[ii] = 0;            }        }        a[answerQuestion.getAnswerPaper()[AnswerNum].getAnswer().length + 199] += mark;        return a;    }    public void JudgeAnswer() {        int mark = 0;        int c[] = new int[answerQuestion.getAnswerPaper()[AnswerNum].getAnswer().length + 200];        int a[] = new int[answerQuestion.getAnswerPaper()[AnswerNum].getAnswer().length + 200];        for (int i = 1; i < delete.getDeleteNum().length; i++) {            if (delete.getDeleteNum() < question.getStandardAnswer().length)                question.getStandardAnswer()[delete.getDeleteNum()] = "laji";        }        int b = answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum().length;//answerQuestion.getAnswerPaper()[AnswerNum].getAnswer().length;        answerQuestion.getAnswerPaper()[AnswerNum].bubble();        for (int j = 1; j < answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum().length; j++) {            for (int i = 1; i < answerQuestion.getAnswerPaper()[AnswerNum].getAnswer().length; i++) {//临时尝试一下,可能答卷的答案不按套路出牌                if (answerQuestion.getAnswerPaper()[AnswerNum].getAnswerNum() == j) {                    a = this.printResult(i, mark, a, j);                    break;                }                if (i == answerQuestion.getAnswerPaper()[AnswerNum].getAnswer().length - 1) {                    a[j] = 0;                    System.out.println("answer is null");                }            }        }        if (answerQuestion.getAnswerPaper()[AnswerNum].getAnswer().length == 1) {            for (int i = 1; i < answerQuestion.getPaper()[AnswerNum].getPaperQuestionNum().length; i++) {                System.out.println("answer is null");            }        }        for (int i = 1; i < studentId.getStudentId().length; i++) {            if (answerQuestion.getAnswerPaper()[AnswerNum].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()[AnswerNum].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[answerQuestion.getAnswerPaper()[AnswerNum].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[length];        for (int i = 1; i < length; i++) {            this.input = input;        }    }    public void setInput(String[] input, int length) {        this.input = new String[length];        for (int i = 1; i < length; i++) {            this.input = input;        }    }    public String[] JudgeQuestion() {        for (int i = 1; i
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

王柳

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表