c++遍历数组
来源:互联网 发布:手机噪音检测软件 编辑:程序博客网 时间:2024/06/05 19:10
// first C plus.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"#include "iostream"using namespace std;int main(){ const int n = 10; int array[n]; int temp; for (int i = 0; i < n; i++) { cin >> temp; array[i] = temp; temp = 0; } for (int i = 0; i < n; i++) { cout << "array["<<i<<"]:"<<array[i]<<endl; } return 0;}
获取数组长度的方法
sizeof,计算数据类型的长度
#include "stdafx.h"#include "iostream"using namespace std;int main(){ const int n = 10; int arr[n]; for (int i = 0; i < sizeof(arr)/sizeof(int); i++) { arr[i] = i; cout << arr[i] << endl; } return 0;}
指针遍历数组
#include "stdafx.h"#include "iostream"using namespace std;int main(){ const int n = 10; int arr[n]; int *p; p = arr; for (int i = 0; i < sizeof(arr)/sizeof(int); i++) { arr[i] = i; } for (int i = 0; i < sizeof(arr) / sizeof(int); i++) { cout << *p; p++; } return 0;}
0 0
- C语言数组遍历
- c指针遍历数组
- 数组三 访问遍历 (c#)
- object c 数组遍历与排序
- [c++]基于数组的二叉树遍历
- 【C++】利用指针表达式遍历数组
- 【C++】结构指针遍历结构数组
- c #遍历数组和其他方法
- c语言遍历字符串数组的方法
- C语言编程-指针遍历二维数组
- C语言 使用指针遍历二维数组
- 数组遍历及求和(C语言)
- C语言 通过指针,数组名 遍历一位数组
- 遍历数组
- 遍历数组
- 数组遍历
- 遍历数组
- 遍历数组
- 装配Bean(三)
- 最近用到的命令
- C语言数组
- 堆--优先队列
- 404_根据uri拿到路径
- c++遍历数组
- 简单实例化解析安卓Thread线程
- 求π近似值
- 蒙特卡洛方法——玩具例子(1)圆周率
- C# Socket简单例子(服务器与客户端通信)
- 慎用git stash save -a
- 158象棋(13)
- Android应用安全机制
- AFNetworking等待网络请求,继续同步操作