不同语言的For循环
Shell中的两种样式
# 样式一:
- for i in 1 2 3
- do
- echo $i
- done
- # 样式二:
- for i in 1 2 3;do echo $i;done
- JAVA
- for(int i = 0; i < 5; i++){
- //循环语句;
- }
- PHP
- for ($i = 0; $i < 5; $i++) {
- # statements;
- }
- VB
- For i = 1 To 5
- ===PASCAL===
- for not i=1 do
- begin
- i=0;
- writeln('Go on!');
- end.
-
- '循环语句
- Next i
- swift
- var x = 0
- for i in 1...100{
- x += i
- }
- print(x)
- //5050
- for _ in 1...100{
- x += 1
- }
- print(x)
- // 100
- var box = [1,2,3,4,5]
- for i in box{
- print(i)
- }
- /*
- 1
- 2
- 3
- 4
- 5
- */
复制代码
---
|