ForNext
Only Do What Only You Can Do
030. 配列の各要素に先頭から順に 1,2,3,4,5 を代入して表示
VBScript
JScript
Perl
更新日 : 2010.10.18
$score[0] = 1; $score[1] = 2; $score[2] = 3; $score[3] = 4; $score[4] = 5; print "点数1 = $score[0]\n"; print "点数2 = $score[1]\n"; print "点数3 = $score[2]\n"; print "点数4 = $score[3]\n"; print "点数5 = $score[4]\n";
L:\>perl lesson_05_030.pl 点数1 = 1 点数2 = 2 点数3 = 3 点数4 = 4 点数5 = 5
PHP
更新日 : 2010.11.03
<?php $score[0] = 1; $score[1] = 2; $score[2] = 3; $score[3] = 4; $score[4] = 5; print "点数1 = $score[0]\n"; print "点数2 = $score[1]\n"; print "点数3 = $score[2]\n"; print "点数4 = $score[3]\n"; print "点数5 = $score[4]\n"; ?>
L:\>php lesson_05_030.php 点数1 = 1 点数2 = 2 点数3 = 3 点数4 = 4 点数5 = 5
Python
更新日 : 2010.11.17
# coding: Shift_JIS score = range(5) print "点数1 = %d" % score[0] print "点数2 = %d" % score[1] print "点数3 = %d" % score[2] print "点数4 = %d" % score[3] print "点数5 = %d" % score[4] print score[0] = 1 score[1] = 2 score[2] = 3 score[3] = 4 score[4] = 5 print "点数1 = %d" % score[0] print "点数2 = %d" % score[1] print "点数3 = %d" % score[2] print "点数4 = %d" % score[3] print "点数5 = %d" % score[4]
N:\>python lesson_05_030.py 点数1 = 0 点数2 = 1 点数3 = 2 点数4 = 3 点数5 = 4 点数1 = 1 点数2 = 2 点数3 = 3 点数4 = 4 点数5 = 5
Ruby
更新日 : 2010.11.01
score = [] score[0] = 1 score[1] = 2 score[2] = 3 score[3] = 4 score[4] = 5 print "点数1 = #{score[0]}\n" print "点数2 = #{score[1]}\n" print "点数3 = #{score[2]}\n" print "点数4 = #{score[3]}\n" print "点数5 = #{score[4]}\n"
L:\>ruby l:\lesson_05_030.rb 点数1 = 1 点数2 = 2 点数3 = 3 点数4 = 4 点数5 = 5
PowerShell
Scala
F#
C
更新日 : 2010.10.08
#include <stdio.h> int main(int argc, char* argv[]) { int score[5]; score[0] = 1; score[1] = 2; score[2] = 3; score[3] = 4; score[4] = 5; printf("点数1 = %d\n", score[0]); printf("点数2 = %d\n", score[1]); printf("点数3 = %d\n", score[2]); printf("点数4 = %d\n", score[3]); printf("点数5 = %d\n", score[4]); return 0; }
R:\>lesson030\project1.exe 点数1 = 1 点数2 = 2 点数3 = 3 点数4 = 4 点数5 = 5
C++
C++Builder
VC++
C#
Java
更新日 : 2010.11.05
class Lesson030 { public static void main(String[] args) { int[] score = new int[5]; score[0] = 1; score[1] = 2; score[2] = 3; score[3] = 4; score[4] = 5; System.out.printf("点数1 = %d\n", score[0]); System.out.printf("点数2 = %d\n", score[1]); System.out.printf("点数3 = %d\n", score[2]); System.out.printf("点数4 = %d\n", score[3]); System.out.printf("点数5 = %d\n", score[4]); } }
L:\>java Lesson030 点数1 = 1 点数2 = 2 点数3 = 3 点数4 = 4 点数5 = 5
Objective-C
D
VB
VB.NET
Delphi
更新日 : 2010.09.24
program Project1; {$APPTYPE CONSOLE} uses SysUtils; var score: array[1..5] of Integer; begin score[1] := 1; score[2] := 2; score[3] := 3; score[4] := 4; score[5] := 5; writeln(format('点数1 = %d', [score[1]])); writeln(format('点数2 = %d', [score[2]])); writeln(format('点数3 = %d', [score[3]])); writeln(format('点数4 = %d', [score[4]])); writeln(format('点数5 = %d', [score[5]])); end.
S:\>lesson030\project1.exe 点数1 = 1 点数2 = 2 点数3 = 3 点数4 = 4 点数5 = 5