有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在4D+阵列中的实际应用

我今年一直在学习java和C++,我很好奇;4维甚至5维数组有什么实际用途?我的老师基本上说,如果你想使用四维数组,你使用的数据类型是错误的

您是否使用过5维数组中的4维(或更多维)数组?你用它干什么?你能想到它们有什么实际用途

谢谢


共 (5) 个答案

  1. # 1 楼答案

    您可能正在运行地球物理模拟,其中有一个3D区域,例如油田,并且您正在测量在该区域不同点(油、水、砂、多孔岩石等)发现的不同物质的相对数量。这个位置可能有三个维度,而你所看到的物质可能有一个维度

  2. # 3 楼答案

    例如一个库存系统,牛仔裤可以通过

     inventory[size][length][color][fit] = number_received
    

    只是有点做作。以这种方式构造数据库不会有问题,但它看起来确实像代码一样有趣

  3. # 4 楼答案

    4D阵列的实际用途是跟踪3d对象,可以跟踪[x-cord][y-cord][z-cord][time]。该4D阵列将是4D阵列的有用用途。这可以跟踪一系列的线和时间,数组中的值可以表示对象的速度

    Speed = arr[5][9][6][1500];
    

    这将记录物体在x线5,y线9,z线6时的速度,也就是说,它已经活了1500秒

    对于您的5D阵列:

    int left; //#of cars left in world
    left = allCars[year][brand][color][condition][horsepower];
    

    品牌计数是一个整数(有一个值表,即法拉利=1,与颜色相同。条件可能是0被破坏,1是全新的)

    然后你会发现1947年法拉利的#是红色的,全新的状态,200马力

    一般来说,您可以使用多维数组来跟踪大型数据库

  4. # 5 楼答案

    您可以创建一个Sodoku hypercube with 4 dimensions,然后将用户输入的数字存储到4维整数数组中

    Rotating 4D hypercube (GIF movie). Imagine a person who lives in 4 spatial dimensions, watching a hypercube rotate. The 4-dimensional person has a 3-dimensional retina in each of its 2 eyes (two eyes suffice for depth perception, even in 4D). Each retina records a 3-dimensional image.

    This image shows what the 4-dimensional person sees, with the extra dimension shown as a variation in colour. That is, the horizontal, vertical, and `colour' directions correspond to the 3 directions on the 3-dimensional retina of the 4-dimensional person. The vertical bar to the right of the picture shows the correspondence between colour and position in the extra dimension.

    您也可以检查Tesseract