2020 second

2020 second

  Let me talk about the group first. I have been looking at algorithms recently, but no one taught the algorithm at all, so I didn’t know where to start, so I was confused for a while. Recently I was learning some data structures, but the jq requested by the group did not look at it, and I was a little flustered. Today I understand a case of the Tower of Hanoi, and share it here.
public class hannuota {
    
    
	private static int sum=0;//计算步数
	public static void main(String[] args) {
    
    
		hanoi(4 , '1' , '2' , '3');
		System.out.println("最少移动"+sum+"步");
	}
	/*
	 * n:几层塔
	 * X:柱子1
	 * Y:柱子2
	 * Z:柱子3*/
	public static void hanoi(int n,char X,char Y,char Z) {
    
    
		if(n==1) {
    
    
			/*以Y为中介,从X移动到Z(这里指的是最下面的那一个)*/
			System.out.println("移动"+X+"--->"+Z);
			sum++;
			return;//return千万不要忘了
		} 
		hanoi(n-1,X,Z,Y);//以Z为中介,将n-1块从X移到Y
		hanoi(1,X,Y,Z);	//此时n-1块已经在Y上了,这个是将最后一块从X移动到Y
		hanoi(n-1,Y,X,Z);//把Y上n-1个以X为中介移动到Z上(最后一步)
	}
}

Insert picture description here
  Then comes daily learning. Recently, something very interesting happened. A classmate of Zhengzhou University of Light Industry asked me to listen to their advanced mathematics class. I joined the DingTalk group as his parent, so many interesting things happened in the class. There is another thing I found different from the teachers in our school: after they finished explaining the knowledge points and sample questions, they took out the postgraduate entrance examination questions related to the knowledge points. I think they did it very well. Our college rarely wants to pass the postgraduate entrance examination. , There are fewer candidates for the postgraduate entrance examination, and I feel that neither the teacher nor herself pays much attention to the postgraduate entrance examination. . I will not say too much here myself. . .
  Finally, I hope that Wuhan will get better soon, that the epidemic will end sooner, return to school sooner, and end my sinful (waste of time) vacation.

Guess you like

Origin blog.csdn.net/weixin_45956597/article/details/104597367