Two sum: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) |
No edit summary |
||
Line 2,273: | Line 2,273: | ||
1 | 2 4 | |
1 | 2 4 | |
||
+---------+</lang> |
+---------+</lang> |
||
=={{header|Vala}}== |
|||
<lang Vala>void main() { |
|||
int arr[] = { 0, 2, 11, 19, 90 }, sum = 21, i, j, check = 0; |
|||
for (i = 0; i < 4; i++) { |
|||
for ( j = i+1; j < 5; j++) { |
|||
if (arr[i] + arr[j] == sum) { |
|||
print("[%d,%d]",i,j); |
|||
check = 1; |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
if (check == 0) |
|||
print("[]"); |
|||
}</lang> |
|||
{{out}} |
|||
<pre>[1,3]</pre> |
|||
=={{header|VBA}}== |
=={{header|VBA}}== |