Leser: 1
10 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
int main(void)
{
int array[10] = {1,2,3,4,5,6,7,8,9,0};
int n = 0;
while (array[n])
{
std::cout << array[n] << std::endl;
n++;
}
return 0;
}
1
2
3
4
5
6
7
8
@array = (1,2,3,4,5,6,7,8,9,0)
$n = 0;
while(defined($array[$n]))
{
print "$array[$n]\n";
$n++;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#define ARRAYLEN 10
int main(void)
{
int array[ARRAYLEN] = {1,2,3,4,5,6,7,8,9,0};
int n = 0;
while (n < ARRAYLEN)
{
std::cout << array[n] << std::endl;
n++;
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> array(10);
vector<int>::iterator array_iter = array.begin();
// 1 bis 10 zuweisen
for (int i=1; array_iter != array.end(); ++i) {
*array_iter++ = i;
}
// einfach Zuweisung an letztes Element
array[array.size()-1] = 0;
// Array ausgeben
array_iter = array.begin();
while (array_iter != array.end()) {
cout << *array_iter << " ";
++array_iter;
}
cout << endl;
return 0;
}
1
2
3
4
5
6
7
8
9
10
#include <iostream>
int main(void)
{
int array[10] = {1,2,3,4,5,6,7,8,9,0};
for(int i = 0; i < sizeof(array) / sizeof(int); i++)
std::cout << array[i] << std::endl;
return 0;
}
10 Einträge, 1 Seite |