删除排序数组的重复数字

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{   int length,a,s,i;
    cout<<"请输入数组长度";
 cin>>length;
 int *p=new int[length];

 for(s=0;s<length;s++)
 {cout<<"请输入数字";
   cin>>p[s];}

  for(i=0;i<length-1;i++)
 {  if (p[i]==p[i+1])
 
  length--;
  }

        cout<< "该数组长度为:"<<length << endl;
 
 
 return 0;
}

posted @ 2017-03-08 19:37  听瞎子唱歌  阅读(98)  评论(0编辑  收藏  举报