数组的输出
来源:互联网 发布:淘宝号申请免费注册 编辑:程序博客网 时间:2024/05/21 11:16
https://github.com/Mooophy/Cpp-Primer/blob/master/ch03/ex3_44.cpp
<textarea readonly="readonly" name="code" class="c++">#include<iostream>
using namespace std;
int main(int argc, char *argv[])
{
int ia[3][4] = { 0,1,2,3,4,5,6,7,8,9,10,11 };
//for loop
for (size_t i = 0; i != 3; i++)
{
for (size_t j = 0; j != 4; j++)
cout << ia[i][j] << ' ';
cout << endl;
}
//range for 除了内层的循环外,其他所有的循环的控制变量应该都是引用型
for (auto &row : ia)//&引用
{
for (auto col : row)
cout << col<<' ';
cout <<endl;
}
for (int(&row)[4] : ia)
{
for (int col : row)
cout << col <<' ';
cout << endl;
}
//using pointers
for (int(*row)[4] = ia; row != ia + 3; row++)
{
for (int *col = *row; col != *row + 4; col++)
cout << *col << ' ';
cout << endl;
}
for (auto p = ia; p != ia + 3; p++)
{
for (auto q = *p; q != *p + 4; q++)
cout << *q << ' ';
cout << endl;
}
// a range for to manage the iteration
// use type alias
using int_array = int[4];
for (int_array& p : ia)
{
for (int q : p)
cout << q << ' ';
cout << endl;
}
return 0;
}
0 0
- 数组的快速输出
- 字符数组的输出
- 二维数组的输出
- 数组的输出问题
- 数组的输出
- 数组的逆序输出
- 二维数组的输出
- 数组的逆向输出
- 数组的调试输出
- 数组的输出
- 数组的逆序输出
- 数组的输出
- 数组的逆序输出
- 数组的格式化输出
- 螺旋数组的输出
- 数组的倒序输出
- 交错数组的输出
- 多维数组的输出
- 逆水行舟问题
- WPF基础到企业应用系列6——布局全接触
- ORACLE 中的 ROW_NUMBER() OVER() 分析函数的用法
- OkHttp解析系列-开篇
- Map<K,V>
- 数组的输出
- struts2中 jsp页面 空文本框传值 及action层不同类型的判断
- 分解质因数
- manacher算法详解
- hdu 1171 Big Event in HDU (01背包)
- [LeetCode] H-Index
- Linux Scheduling Domains
- hdu 2037 今年暑假不AC
- CCPC 2015 A题