Logo

Programming-Idioms

History of Idiom 7 > diff from v99 to v100

Edit summary for version 100 by programming-idioms.org:
Admin deletes impl 4120: OT

Version 99

2020-11-22, 00:29:37

Version 100

2020-11-22, 00:33:27

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Variables
i,x,items
Variables
i,x,items
Extra Keywords
traverse traversal
Extra Keywords
traverse traversal
Code
for (std::size_t ix = 0; ix < items.size(); ++ix) {
	for (std::size_t jx = 0; jx < items[ix].size(); ++jx)
  		std::cout << "Item " << jx << " = " << items[ix][jx] << std::endl;
	}
}