通过二维阵列对角迭代

时间:2017-11-19 09:47:21

标签: java arrays loops 2d

我必须遍历一个二维的chars数组。我已经有了代码来迭代/但是当我遇到时我已经迷失了。

这是我的二维数组;

import React from 'react';
import { StyleSheet, StatusBar, View } from 'react-native';
import { TabNavigator } from 'react-navigation';
import PageLecture from './js/PageLecture';
import PageSalat from './js/PageSalat';
import PageHadiths from './js/PageHadiths';
import PageParametres from './js/PageParametres';

export default class App extends React.Component {
    render() {
        // This is not working
        // return (
        //     <View>
        //         <View>
        //             <StatusBar hidden={true}/>
        //         </View>
        //
        //         <ReactCoran />
        //     </View>
        // );

        // This is not working
        // return (
        //     <View>
        //         <StatusBar hidden={true}/>
        //         <ReactCoran />
        //     </View>
        // );

        // This is working but status bar is displayed
        return (
            <ReactCoran />
        );
    }
}


const ReactCoran = TabNavigator({
    Lecture: {
        screen: PageLecture,
    },
    Salat: {
        screen: PageSalat,
    },
    Hadith: {
        screen: PageHadiths,
    },
    Parametres: {
        screen: PageParametres,
    }
},
{
    tabBarPosition: 'bottom',
    animationEnabled: false,
    tabBarOptions: {
        allowFontScaling: true,
        activeTintColor: '#000000',
        showIcon: true,
        showLabel: false,
        activeBackgroundColor: '#ff0000',
        style: {
            backgroundColor: '#aa0000',
        },
        indicatorStyle: {
            height:2,
            backgroundColor: '#ffffff',
        }
    },
});

我已经

a,v,i,o,n,l
t,o,t,o,l,l
m,a,r,c,o,e
s,a,g,r,c,i
o,e,n,z,o,g
s,t,r,a,r,u

我需要

a
tv
moi
....

他是迭代/:

的投手
l
nl
ole
....

2 个答案:

答案 0 :(得分:0)

试试这个:

while($a = mysqli_fetch_assoc($get_files))
        {
            $path_parts = pathinfo($a['fajl_file']);
            $extension = $path_parts['extension'];

            $path = $host.'/documents/'.$a['fajl_file'];

            echo '<tr>
                <td>'.html($a['fajl_nev']).'</td>
                <td>'.date_substr($a['fajl_datetime']).'</td>
                <td>'.$extension.'</td>
                <td>'.filesize($path).'</td>
                <td class="table_text_center">
                    <a class="table_delete_link delete_data" id="" href="#"><i class="fa fa-download"></i></a>
                </td>
            </tr>';
        }

答案 1 :(得分:0)

您可以使用自己的代码。您唯一需要做的就是首先转置矩阵。我已经为你编写并测试了它。 myArray是您作为输入提供给我们的数组,yourArray是您需要将代码用作lista的代码。

for (int i = 5; i >= 0; i--) {
    for (int j = 0; j <= 5; j++) {
       yourArray[5 - i][j] = myArray[j][i];
    }
}