c语言
#include<stdio.h>
int main()
{
int a[5] ;
int i ;
for( i = 0; i < 5; i++ )
{
scanf("%d",&a[i]) ;
}
for( i = 0; i < 5; i++ )
{
printf("%d ",a[i]) ;
}
return 0;
}
c++
#include<iostream>
using std::cin;
using std::cout;
int main()
{
int a[5] ;
int i ;
for( i = 0; i < 5; i++ )
{
cin >> a[i] ;
}
for( i = 0; i < 5; i++ )
{
cout << a[i] <<" " ;
}
return 0;
}
c#
using System;
namespace ArrayApplication
{
class MyArray
{
static void Main(string[] args)
{
int [] n = new int[10]; /* n 是一个带有 10 个整数的数组 */
int i,j;
/* 初始化数组 n 中的元素 */
for ( i = 0; i < 10; i++ )
{
n[ i ] = i + 100;
}
/* 输出每个数组元素的值 */
for (j = 0; j < 10; j++ )
{
Console.WriteLine("Element[{0}] = {1}", j, n[j]);
}
Console.ReadKey();
}
}
}
输出结果
Element[0] = 100
Element[1] = 101
Element[2] = 102
Element[3] = 103
Element[4] = 104
Element[5] = 105
Element[6] = 106
Element[7] = 107
Element[8] = 108
Element[9] = 109
Python
intArr = [1, 4, 2, 5, 3, 7, 9, 0] #整型数组
strArr = ["北京", "上海", "杭州", "深圳"] #字符串数组
mixArr = [1, 3.44, "hello", [1, 2, 3]] #混合数组
emptyArr = [] #空数组
#控制台输出
print(intArr)
print(strArr)
print(mixArr)
print(emptyArr)
输出结果
来源:https://blog.csdn.net/qzc70919700/article/details/72983513/
java
package hello;
public class helloo {
public static void main(String[] args) {
// TODO Auto-generated method stub
java.util.Scanner input = new java.util.Scanner(System.in);
int[] a = new int[5];
for(int i = 0; i < a.length; i++)
{
a[i] = input.nextInt();
}
for (int i = 0; i < a.length; i++)
{
System.out.print(a[i] + " ");
}
}
}