练习3.35

编写一段程序,利用指针将数组中的元素置为0


#include <iostream>
#include <iterator>
using namespace std;
int main()
{
    int a[]={1,2,3,4,5,6,7,8};
    int *p=begin(a);
    int *p1=end(a);
    for (*p;p!=p1;*p++){
        *p=0;
    }
    for(auto c:a)
        cout<<c<<endl;
    return 0;
}


posted @ 2014-12-25 15:22  Song_4  阅读(95)  评论(0编辑  收藏  举报