c++配列操作(繰返し、並べ替え、bitset)

2699 ワード

//  :  
//      ,a[]={1,1,1,1,1,2,2,2,2,3,3,3,4,5,6}  
//       1,2,3,4,5,6.(       ,         ).
#include 
using namespace std;

template
class Bitset
{
	public:
	Bitset()
	{
			_Tidy();//  _Tidy()          0.
	}
	void Show()//  01 .
	{
		for(int _I=0;_I<_n cout="" bool="" test="" _p="" int="" _i="_P/32;" return="">>(_P%32))&0x1;
	}
	void _Tidy()
	{
		for(int _I=0;_I<_w a="" void="" set="" _p="" int="" _i="_P/32;" printf="" for="" test="" private:="" typedef="" long="" enum="" _w="_Nw+1};" main="" bitset=""> a;
	int b[]={1,1,1,1,2,2,3,3,34,2,423,42,34,23,1,1,3,213,123,21,3,3,4,32,543,5,46,3,45,35,23,42,3};
	for(int i=0;i<33;i++)
	{
	a.set(b[i]);
	}
	a.printf();
}

次の2つの乱暴な方法があります.
#include   
using namespace std;  
  
struct Node  
{  
    int data;  
    Node *next;  
    Node():data(-1),next(NULL){}  
};  
//          ,             。  
class Hash  
{  
    public:  
    Hash(int a[],int n)  
    {  
        NodeTable = new Node[7];  
        for(int i=0;idata!=a[i])  
            {  
                p=p->next;  
            }  
            if(p==NULL)  
            {  
                Node *s = new Node();  
                s->data = a[i];  
                NodeTable[index].next=s;  
            }  
        }  
    }  
    void Show()  
    {  
        for(int i=0;i<7;i++)  
        {  
            if(NodeTable[i].data!=-1)  
            {  
             Node *p = NodeTable[i].next;  
                while(p!=NULL)  
                {  
                    cout<data<next;  
                }  
            }     
        }  
        cout<  
#include   
using namespace std;  
//      ,           ,        。  
void Grial(int a[],int& n)//   n     ,                    ,    ,       n     。  
{  
    int i=0;  
    int j;  
    int k;  
    for(;i=n)  
                {  
                    i++;  
                }  
        }  
        if(a[i]==a[i+1])  
        {  
            for(k=i;k