借助AI,直接刷真题也能通关软考

前言

软考考察的特点是广度为主,深度为辅,因此我们需要了解每个知识点的基本概念和原理,而不是过于集中于某一个知识点进行深入研究。而AI最擅长的就是理解和运用知识点,能够帮助我们快速掌握知识点,缩短通关软考周期。

学习环境

  1. 历年真题

建议使用 APP 刷题,方便记录错题,查看解析,把控进度。

  1. AI 助手

LLama3 70b Qwen 110b GPT4 都可以,LLama3 思维比较灵活,Qwen 中文训练语料充足,GPT4 是最强王者。

实战演示

下面我以软件设计师考试为例,分别对选择题和案例题进行实战演示。

1. 选择题

选择题命题的趋势是逐步淘汰概念记忆题型,增加计算推理题型。
如下题考察海明码知识点,是典型的计算推理题。

设信息位是8位,用海明码来发现并纠正1位出错的情况,则校验位的位数至少为(3)
A. 1
B. 2
c. 4
D. 8

假设我们不知道这个知识点,就求助AI,来看看它如何进行解答。
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
非常的详细,推理的过程和计算结果都是正确的,思路十分清晰。
如此一来,我们就掌握了下面的公式。
2 r ≥ n + r + 1 2^r \geq n + r + 1 2rn+r+1

2. 案例题

阅读下列说明和 Java 代码,将应填入(n) 处的字句写在答题纸的对应栏内。

【说明】在某系统中,类 Interval 代表由下界(lower bound)和上界(upper bound)定义的区间。要求采用不同的格式显示区间范围。如:[lower bound,upper bound]、[lower bound…upper bound]、[lower bound-upper bound] 等。现采用策略 Strategy 模式实现该要求。

enum TYPE {
	COMMA,
	DOTS,
	LINE
}
interface PrintStrategy {
	public1;
}
class Interval {
	private double lower;
	private double upper;
	public Interval(double lower, double upper) {
		this.lower = lower;
		this.upper = upper;
	}
	public double getLower() { return lower; }
	public double getUpper() { return upper; }
	public void printIntervals(PrintStrategy ptr) {2;
	}
}
class PrintIntervalsComma implements PrintStrategy {
	public void doPrint(Interval val) {
		System.out.println("[" + val.getLower() + "," + val.getUpper() + "]");
	}
}
class PrintIntervalsDots implements PrintStrategy {
	public void doPrint(Interval val) {
		System.out.println("[" + val.getLower() + "..." + val.getUpper() + "]");
	}
}


class PrintIntervalsLine implements PrintStrategy {
	public void doPrint(Interval val) {
		System.out.println("[" + val.getLower() + "-" + val.getUpper() + "]");
	}
}
public class Main {
	public static PrintStrategy getStrategy(TYPE type) {
		PrintStrategy st = null;
		switch (type) {
			case COMMA:3;
			break;
			case DOTS:4;
			break;
			case LINE:5;
			break;
		}
		return st;
	}
	public static void main(String[] args) {
		Interval a = new Interval(1.7, 2.1);
		a.printIntervals(getStrategy(TYPE.COMMA));
		a.printIntervals(getStrategy(TYPE.DOTS));
		a.printIntervals(getStrategy(TYPE.LINE));
	}
}

这段代码定义了一个枚举TYPE来表示不同的打印间隔的方式,以及一个接口PrintStrategy用于定义打印策略。Interval类使用了策略模式,通过传入不同的PrintStrategy实例来改变打印间隔的方式。getStrategy方法根据传入的TYPE返回相应的策略实现类的实例。在main方法中,通过这个策略模式实现了对同一个间隔使用不同方式打印的效果。

AI解答如下:

public void doPrint(Interval val);

  • This is the method signature for the PrintStrategy interface.

ptr.doPrint(this);

  • This calls the doPrint method on the provided PrintStrategy object, passing the current Interval object as an argument.

st = new PrintIntervalsComma( );

  • This sets the PrintStrategy object to an instance of PrintIntervalsComma.

st = new PrintIntervalsDots( );

  • This sets the PrintStrategy object to an instance of PrintIntervalsDots.

st = new PrintIntervalsLine( );

  • This sets the PrintStrategy object to an instance of PrintIntervalsLine.

我们来看看他的解题思路

Here’s my thought process when filling in the blanks:

Step 1: Understanding the problem

I read through the code and understood that it’s a Java program that uses an enum TYPE to represent different types of printing strategies for intervals. There are three types of printing strategies: COMMA, DOTS, and LINE. The program has an interface PrintStrategy that defines a method doPrint(Interval val) to print an interval using a specific strategy.

Step 2: Filling in the ptr.doPrint()

I started by looking at the PrintStrategy interface and saw that it was missing a method signature. I knew that the method should take an Interval object as an argument, so I filled in the blank with public void doPrint(Interval val);.

Next, I looked at the Interval class and saw that it had a method printIntervals(PrintStrategy ptr) that was missing an implementation. I knew that this method should call the doPrint method on the provided PrintStrategy object, passing the current Interval object as an argument. So, I filled in the blank with ptr.doPrint(this);

Step 3: Implementing the printing strategies

I then looked at the three classes that implement the PrintStrategy interface: PrintIntervalsComma, PrintIntervalsDots, and PrintIntervalsLine. Each of these classes had a doPrint method that was correctly implemented to print an interval using the corresponding strategy.

Step 4: Completing the getStrategy method

Finally, I looked at the getStrategy method in the Main class, which was missing implementations for each case of the TYPE enum. I knew that each case should return an instance of the corresponding printing strategy class. So, I filled in the blanks with st = new PrintIntervalsComma();, st = new PrintIntervalsDots();, and st = new PrintIntervalsLine();.

Step 5: Reviewing the code

After filling in all the blanks, I reviewed the code to make sure it made sense and was consistent with the problem statement.

That’s my thought process!

  • 16
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

热爱技术的小胡

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值