java模拟刘谦2024春晚扑克牌魔术代码

代码语言:java

所属分类:其他

代码描述:java模拟刘谦2024春晚扑克牌魔术代码

代码标签: java 模拟 刘谦 2024 春晚 扑克牌 魔术 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

import java.util.Arrays;
import java.util.Random;
public class HelloWorld {
  public static void main(String[] args) {
 
        int[] arr = {1, 2, 3, 4};
        System.out.println("选取四张牌:"+ Arrays.toString(arr));
        int[] partition = partition(arr);
        System.out.println("对半撕开并叠在一起:"+ Arrays.toString(partition));
        int[] bottom = bottom(partition, 3);
        System.out.println("按照名字的长度把最上面的牌放到底部:"+ Arrays.toString(bottom));
        int[] insert = insert(bottom);
        System.out.println("最上面三张牌随机插入到五张牌中间:"+ Arrays.toString(insert));
        System.out.println("现在最上面的一张牌是:"+ insert[0]);
        int[] pop = pop(insert);
        System.out.println("把最上面一张牌藏屁股下,还剩:"+ Arrays.toString(pop));
        int[] throwOneOrTwo = throwOneOrTwo(pop, "女");
        System.out.println("男生扔掉最上面一张牌,女生扔两张:"+ Arrays.toString(throwOneOrTwo));
        int[] mysticalWords = mysticalWords(throwOneOrTwo);
        System.out.println("喊出七字真言,每喊一个字将一张牌置底"+ Arrays.toString(mysticalWords));
        int[] leaveOneGoOne = LeaveOneGoOne(mysticalWords);
        System.out.println("然后开始留下一张置底丢一张,直到还剩一张:"+ leaveOneGoOne[0]);
    }
 
    static int[] partition(int[] arr) {
        int[] newArr = new int[arr.length * 2];
        System.arraycopy(arr, 0, newArr, 0, arr.length);
        System.arraycopy(arr, 0, newArr, 4, arr.length);
        return newArr;
    }
 
    //下放 n 个
    static int[] bottom(int[] arr, int n) {
        int[] newArr = new int[arr.length];
        System.arraycopy(arr, n, newArr, 0, arr.length - n);
        System.arraycopy(arr, 0, newArr, arr.........完整代码请登录后点击上方下载按钮下载查看

网友评论0