⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsflying.cpp

📁 用列表实现的队列和栈的算法
💻 CPP
字号:
// DsFlying.cpp : Defines the entry point for the console application.
//
#define _PROGRAMMING_WITH_C_PLUS_PLUS_ 

#include "stdafx.h"
#include "dstype.h"
#include "dsimpl.h"
#include "stdlib.h"
#include "time.h"

SDS_STRING (*errorDetail)(SDS_RESULT errorNo)=NULL;
SDS_RESULT printOut(pssle pEle,sdstd_param inParam,sdstd_param outParam)
{
printf("%d\n",(int)pEle->data);
return SDS_OK;
}


//SDS_RESULT funTest(sdstd_single_list& inList){return SDS_OK;}
SDS_KEYTYPE getSortKey(pssle pEle)
{
return (SDS_KEYTYPE)(pEle->data);
}


int main(int argc, char* argv[])
{  
	
	register int i=0;//the commong counter

//	sdstd_data dataTmp; //the temp data variant
   
	SDS_RESULT errorNo=SDS_OK; // common error number variant
    //errorDetail=pSlist->getErrorExpositor(); // get the error expositor handle
	errorDetail=::sdstd_single_list_impl::errorDetail;
    // for sdstd_single_list testing //CString
	
	pssle pTmp=NULL;

    sdstd_single_list *pSlist=new sdstd_single_list_impl;
    
	sdstd_single_list *pSlistTar=new sdstd_single_list_impl;
   
/*	for(i=0;i<100;i++)
	pSlist->addTail(pSlist->createElement((sdstd_data)i));
	pSlist->traverseThrough(printOut);
   pSlist->reverseList();
    system("pause");
	
	pSlist->traverseThrough(printOut);
    for(i=0;i<20;i++)
	{
     pSlist->getHead(&pTmp);
	
	 errorNo=pSlist->deleteElement(NULL,pTmp);
     //delete pTmp->next;
     printf("%s\n",errorDetail(errorNo));
	 if(errorNo!=SDS_OK) break;

     delete pTmp;
	}
    system("pause");
	pSlist->traverseThrough(printOut);
    */
    for(i=0;i<10000;i++)
	  pSlist->addHead(pSlist->createElement((sdstd_data)i));
  //  pSlist->traverseThrough(printOut);

    clock_t TheTimeBegin=clock();
	pSlist->sortList(::getSortKey,SDS_KEYUP_SORT);  
	printf("Processing lasting time %6.4f\n",(float)(clock()-TheTimeBegin)/CLOCKS_PER_SEC);
    
	  system("pause");
	
  pSlist->traverseThrough(printOut);
	//pSlistTar->copyList(pSlist);
//	system("pause");
//	pSlist->copyList(pSlistTar);
 //   pSlistTar->reverseList();
//	pSlistTar->addHead(pSlistTar->createElement((sdstd_data)-1));
 //   pSlistTar->addTail(pSlistTar->createElement((sdstd_data)100));

	//pSlistTar->traverseThrough(printOut);
	
	//system("pause");
	//pSlist->traverseThrough(printOut);

    
	// pSl ist->traverseThrough(printOut);

	// pSlist->traverseInit();
	//while(pSlist->hasNext())
    // {  int errorNo=pSlist->getNext(&pTmp);
    //	  printf("%d,%s\n",(int)pTmp->data,errorDetail(errorNo));
    // 
	//}

 	//sdstd_single_list_impl *pImpl= new sdstd_single_list_impl();
    //printf("Hello World!\n");

      delete pSlist;
	  delete pSlistTar;
      

     


	 // for sdstd_queue  testing
  /*  
    sdstd_queue *pQueue=new sdstd_queue_impl;
	 pQueue->setSize(50);
     
	for(i=0;i<100;i++)
		printf("%s\n",errorDetail(pQueue->inQueue((sdstd_data)i))); //data entering queue

	while(1)
	{
	errorNo=pQueue->outQueue(&dataTmp);
    if(errorNo!=SDS_OK) break;
	printf("%d\n",(int)dataTmp);

	}


    delete pQueue;
	
	system("pause");
	*/ 

    //for sdstd_stack testing
   /*
	sdstd_stack *pStack=new sdstd_stack_impl;
    //pStack->setSize(50);
   
	for(i=0;i<1000;i++)
		printf("%s\n",errorDetail(pStack->push((sdstd_data)i))); //data entering queue
        // pStack->push((sdstd_data)i);
	while(1)
	{
	errorNo=pStack->pop(&dataTmp);
    if(errorNo!=SDS_OK) break;
    printf("%d\n",(int)dataTmp);
	}

	system("pause");
    delete pStack;
	
*/	
	
	
	
	
	
	
	
	
	
	
	
	return SDS_OK;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -