【Java】用五种语言写数组(用于自己学习)

C语言

#include<stdio.h>

int main()
{
    int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int i;
    for(i=0;i<9;i++)
        printf("%d ",a[i]);
    printf("%d\n",a[9]);
        return 0;
}

C++

#include <iostream>
using namespace std;

int main()
{
    const int len = 6;
    int hours[len];
    cin >> hours[0];
    cin >> hours[1];
    cin >> hours[2];
    cin >> hours[3];
    cin >> hours[4];
    cin >> hours[5];
    cout << hours[0];
    cout << " " << hours[1];
    cout << " " << hours[2];
    cout << " " << hours[3];
    cout << " " << hours[4];
    cout << " " << hours[5] << endl;
    return 0;
}

Python

array_full=[1, 2, 3] 
print(array_full[0])
print(array_full[-1])

Java

package arr;
import java.util.Arrays;
public class arr {
    public static void main(String[]args){
    int[] a={1, 2, 3, 4, 5, 6, 7, 8};
    int[] b=new int[4];
    b=Arrays.copyOfRange(a,2,6);
    System.out.println(Arrays.toString(b));
    }
}

CSS

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>数组</title>
        <script>
            var name=["aaa","bbb","ccc"];
        </script>
    </head>
</html>

 

posted on 2019-11-19 15:34  Hinwya  阅读(214)  评论(0编辑  收藏  举报

导航