题解 | #利用指针遍历数组#
利用指针遍历数组
http://www.nowcoder.com/practice/fd4530358d57455da387df95a19d14c1
#include <iostream>
using namespace std;
int main() {
int arr[6] = { 0 };
int* ptr = arr;
int len = sizeof(arr) / sizeof(int);
for (int i = 0; i < len; i++) {
cin >> arr[i];
}
// write your code here......
for(int i=0;i<len;i++){
if(i==(len-1)){
cout<<*ptr<<endl;
}else{
cout<<*ptr<<" ";
}
ptr++;
}
return 0;
}