• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16declare function print(n:number):string;
17
18for (var i:number = 0; i < 10; i++) {
19    for (var j:number = 0; j < 10; j++) {
20      if (i == j) {
21        print(i);
22      }
23    }
24}
25
26for (var i:number = 0; ; i++) {
27    if (i > 100) {
28        print(i);
29        break;
30    }
31}
32
33for (var i:number = 0; i < 100; i++) {
34    if (i < 99) {
35        continue;
36    }
37    print(i);
38}
39
40var i:number = 0;
41var sum:number = 0;
42while (i < 10) {
43    i++;
44    sum += i;
45}
46print(sum);
47
48var j:number = 0;
49while (j < 100) {
50    j++;
51    if (j == 50) {
52        print(j);
53        break;
54    }
55}
56
57var k:number = 0;
58while (k < 100) {
59    k++;
60    if (k < 99) {
61        k++;
62        continue;
63    }
64    print(k);
65}
66
67i = 0;
68sum = 0;
69do {
70    sum += i;
71    i++;
72} while (i < 100);
73print(sum);
74
75j = 0;
76do {
77    j++;
78    if (j > 100) {
79        print(j);
80        break;
81    }
82} while (true);
83
84k  = 0;
85do {
86    k++;
87    if (k < 100) {
88        continue;
89    }
90    print(k);
91} while (k < 100);
92
93var index:number = 0;
94i = 0;
95if (index == 0) {
96    for (i = 0; ; i++) {
97        if (i > 100) {
98            print(i);
99            break;
100        }
101    }
102} else if (index == 1) {
103    while (i < 100) {
104        i++;
105        if (i < 99) {
106            i++;
107            continue;
108        }
109        print(i);
110    }
111} else {
112    do {
113        i++;
114        if (i > 100) {
115            print(i);
116            break;
117        }
118    } while (true);
119}
120
121index = 1;
122i = 0;
123if (index == 0) {
124    for (i = 0; ; i++) {
125        if (i > 100) {
126            print(i);
127            break;
128        }
129    }
130} else if (index == 1) {
131    while (i < 100) {
132        i++;
133        if (i < 99) {
134            i++;
135            continue;
136        }
137        print(i);
138    }
139} else {
140    do {
141        i++;
142        if (i > 100) {
143            print(i);
144            break;
145        }
146    } while (true);
147}
148
149index = 2;
150i = 0;
151if (index == 0) {
152    for (i = 0; ; i++) {
153        if (i > 100) {
154            print(i);
155            break;
156        }
157    }
158} else if (index == 1) {
159    while (i < 100) {
160        i++;
161        if (i < 99) {
162            i++;
163            continue;
164        }
165        print(i);
166    }
167} else {
168    do {
169        i++;
170        if (i > 100) {
171            print(i);
172            break;
173        }
174    } while (true);
175}
176