• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PrintArray函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PrintArray函数的典型用法代码示例。如果您正苦于以下问题:C++ PrintArray函数的具体用法?C++ PrintArray怎么用?C++ PrintArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PrintArray函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    int N = 0;
    ElementType *A;

    if (argc != 2) return -1;
    N = atoi(argv[1]);
    assert(N != 0);

    A = malloc(sizeof(ElementType)*N);
    assert(A != NULL);
    memset(A,0,N*sizeof(ElementType));


    RandomFillArray(A,N);
    printf("original array:\n");
    PrintArray(A,N);

    printf("sort start:\n");
//	InsertSort(A,N);
//	BubbleSort(A,N);
//	ShellSort_V2(A,N);
//	QuickSort(A,N);
    MergeSort(A,N);
    printf("sort end.\n");

    printf("After sort array is:\n");
    PrintArray(A,N);

    free(A);
    return 0;
}
开发者ID:peterocean,项目名称:datastructure_algorithmanalysis,代码行数:32,代码来源:sort_test.c


示例2: RunQuickSort

void RunQuickSort(void)
{
  int to_partition[] = {2, 1, 3, 7, 1, 3, 6, 4, 8, 3, 4, 1};
  int size = sizeof(to_partition) / sizeof(int);
  PrintArray(to_partition, size);
  Quicksort(to_partition, 0, size);
  PrintArray(to_partition, size);
}
开发者ID:jColeChanged,项目名称:Exploration,代码行数:8,代码来源:main.cpp


示例3: main

int main()
{
   int array[] = {10,9,8,7,6,5,4,3,2,1};
   int len = sizeof(array) / sizeof(int);
   PrintArray(array,len,"直接插入排序前:");
   InsertSort(array,len);
   PrintArray(array,len,"直接插入排序后:");
   return 0;
}
开发者ID:LucasYang7,项目名称:Sort-Algorithm,代码行数:9,代码来源:main.cpp


示例4: main

// main - entry point
int main(int argc, const char * argv[]) {
    int numbers[10] = { 12, 445, 55, 67, 2, 7, 909, 45, 4454, 1 };
    printf("Before Insertion Sort: ");
    PrintArray(numbers, 10);
    InsertionSort(numbers, 10);
    printf("After Insertion Sort: ");
    PrintArray(numbers, 10);
    return 0;
}
开发者ID:retroburst,项目名称:Algorithms,代码行数:10,代码来源:main.c


示例5: main

int main(void)
{
    ElemType* const array = (ElemType*)malloc(sizeof(ElemType)*ARRAY_NUMBER );
    InitalArray(array);
    PrintArray(array);
    BinaryInsertionSort(array,ARRAY_NUMBER );
    printf("排序结果为:");
    PrintArray(array);
    return 0;
}
开发者ID:tangchn,项目名称:data_structure,代码行数:10,代码来源:BinaryInsertionSort.c


示例6: main

int main()
{
	#if 0
	int i;
	int iPos = 0 ;
	int iArr1[]={1,7 , 12 ,15,16,17,19,22,23 , 26};
	int iSize =  sizeof(iArr1)/sizeof(iArr1[0]) ;
	void **pAddr = malloc( iSize * sizeof(void *));
	for(i = 0 ; i < iSize ; ++i)
	{
		pAddr[i] = iArr1 + i ;
	}	
	PrintArray(iArr1 , iSize , &i);
	while(i != -1)
	{
		int iRet = BSearch( pAddr  , sizeof(iArr1)/sizeof(iArr1[0]) , (void *)&i , CompareFunc  ,&iPos);
		if(iRet == 0)
		{
			printf("bingo ! pos:%d\n" , iPos);
		}
		else
		{
			printf("bad luck ! pos:%d\n" , iPos);
		}
		PrintArray(iArr1 , iSize , &i);
	}
	#endif
	int i ;
	int iArr1[] = { 24 , 25};	
	int iArr2[]={1,2,3,4,5 , 8 , 9 , 23 };
	unsigned int iSize1 = sizeof(iArr1)/sizeof(iArr1[0]) ;
	unsigned int iSize2 = sizeof(iArr2)/sizeof(iArr2[0]) ;
	void **p1 = malloc(iSize1 * sizeof(void *));
	void **p2 = malloc(iSize2 * sizeof(void *));
	void **pMerge = (void **)malloc( sizeof(void *)* (iSize1 + iSize2));
	for(i = 0 ; i < iSize1 ; ++i)
        {
                p1[i] = iArr1 + i ;
        }
	for(i = 0 ; i < iSize2 ; ++i)
        {
                p2[i] = iArr2 + i ;
        }
	for(i = 0 ; i < (iSize1 + iSize2) ; ++i)
	{
			pMerge[i] = NULL ;
	}
	Merge(p1 , iSize1 , p2 , iSize2 ,CompareFunc ,  pMerge);
	for(i = 0 ; i < (iSize1 + iSize2) ; ++i)
	{
			printf("%d " , *((int *)pMerge[i]));
	}
	printf("\n");		
	return 0 ;
}
开发者ID:ernestzhang,项目名称:edb,代码行数:55,代码来源:merge.c


示例7: main

void main()
{
	int a[100];
	int n;
	RandomArray(a,n);
	PrintArray(a,n);
	//SimpleSort(a,n);
	BinaryInsertionSort(a,n);
	PrintArray(a,n);
	getch();
}
开发者ID:trankimhieu,项目名称:CTDL-TT,代码行数:11,代码来源:BinaryInsertionSort.cpp


示例8: main

int main()
{
    // data
    int values[] = {32,71,12,45,26,80,53,33}; 
    const unsigned int n = sizeof(values)/sizeof(values[0]);
    std::cout << "value before ="; PrintArray(values, n);

    BubbleSort(values, n);
    std::cout << "value after  ="; PrintArray(values, n);
    return 0;
}
开发者ID:kelleyrw,项目名称:BuddTutorial,代码行数:11,代码来源:bubble_sort.cpp


示例9: main

void main()
{
	int a[100];
	int b[100];
	int n;
	int m = 0;
	RandomArray(a,n);
	CreateNewArray(a,b,n,m);
	PrintArray(a,n);
	PrintArray(b,m);
	getch();
}
开发者ID:trankimhieu,项目名称:KTLT,代码行数:12,代码来源:bai02.cpp


示例10: main2

int main2(void){
	int aScores[20]={0};
	int els = numsof(aScores);
	int i;
	srand((unsigned int)time(NULL));

	RandomArray(aScores);
	PrintArray(aScores);
	BubbleSort(aScores, els);
	PrintArray(aScores);

	return 0;
}
开发者ID:nhlinhmisfit,项目名称:CandC-,代码行数:13,代码来源:BubbleSort.c


示例11: main

void main()
{
	int a[100];
	int h[100];
	int n,k;
	RandomArray(a,n);
	PrintArray(a,n);

	GetSteps(h,k,n);
	ShellSort(a,n,h,k);
	PrintArray(a,n);
	getch();
}
开发者ID:trankimhieu,项目名称:CTDL-TT,代码行数:13,代码来源:Shell+Sort.cpp


示例12: main

int main(void)
{
    int i;
    u64 begin,end;
    ElemType* const array = (int*)malloc(sizeof(int)*ARRAY_NUMBER );
    InitalArray(array);
    PrintArray(array);

    ElemType* tempArray1 =  (int*)malloc(sizeof(int)*ARRAY_NUMBER );
    ElemType* tempArray2 =  (int*)malloc(sizeof(int)*ARRAY_NUMBER );
    ElemType* tempArray3 =  (int*)malloc(sizeof(int)*ARRAY_NUMBER );
    for(i = 0; i < ARRAY_NUMBER ; i++)
    {
        tempArray1[i] = array[i];
        tempArray2[i] = array[i];
        tempArray3[i] = array[i];
    }

    //冒泡排序
    Rdtsc(&begin);
    BubbleSort(array);
    Rdtsc(&end);
    printf("冒泡排序后的数组是:");
    PrintArray(array);
    printf("花费时间为:%llu \n",end - begin);

    Rdtsc(&begin);
    BubbleSort2(tempArray1);
    Rdtsc(&end);
    printf("冒泡排序2后的数组是:");
    PrintArray(tempArray1);
    printf("花费时间为:%llu \n",end - begin);

    Rdtsc(&begin);
    BubbleSort3(tempArray2);
    Rdtsc(&end);
    printf("冒泡排序3后的数组是:");
    PrintArray(tempArray2);
    printf("花费时间为:%llu \n",end - begin);
    
    Rdtsc(&begin);
    BubbleSort4(tempArray3);
    Rdtsc(&end);
    printf("冒泡排序4后的数组是:");
    PrintArray(tempArray3);
    printf("花费时间为:%llu \n",end - begin);

    return 0;
}
开发者ID:tangchn,项目名称:data_structure,代码行数:49,代码来源:BubbleSort.c


示例13: main

int main()
{
    aType testArray[] = { 7, 13, 1, 3, 10, 5, 2, 4 };
    int nA = sizeof(testArray)/sizeof(aType);

    cout << "nA: "  << nA << endl;

    cout << "Initial array contents:" << endl;
    PrintArray( testArray, nA );

    SelectionSort( testArray, nA );

    cout << "Final array contents:" << endl;
    PrintArray( testArray, nA );
}
开发者ID:ThereIsNoEscape,项目名称:uidaho,代码行数:15,代码来源:selSort.cpp


示例14: SelectionSort

void  SelectionSort( aType A[], int nElements )
{
    int iSmallest;
    aType  tmp;
   
    cout << "------------------------" << endl;
    cout << "In SelectionSort():" << endl;

    for( int i = 0 ; i < nElements ; i++ )
    {
        cout << " Pass: " << i << endl;
        iSmallest = IndexOfSmallest( A, i, nElements-1 );
            //  swap
        if( iSmallest > i )
        {
            tmp = A[i];
            A[i] = A[iSmallest];
            A[iSmallest] = tmp;
        }

        PrintArray( A, nElements );
    }

    cout << "SelectionSort() finished" << endl;
    cout << "------------------------" << endl;
}
开发者ID:ThereIsNoEscape,项目名称:uidaho,代码行数:26,代码来源:selSort.cpp


示例15: BubbleSort

//Function sorts pointer array according to input order
//Input: pointer array, size of array, sort order
//Output: pointer array sorted by sort order
void BubbleSort(int *array, int size, int order)
{
	int a;
	int loop = 1;

	while (loop)
	{
		loop = 0;

		for (a = 0; a < size-1; a++)
		{
			//Sorts array in ascending order
			if (order == 1)
				if (*array > *(array+1))
					{
						Swap(array, array+1);
						loop = 1;
					}

			//Sorts array in decending order
			if (order == -1)
				if (*array < *(array+1))
					{
						Swap(array, array+1);
						loop = 1;
					}

			array++;
		}

		array = array - (size - 1);
	}

	PrintArray(array, 20);
}
开发者ID:Yuwain,项目名称:School,代码行数:38,代码来源:Lab4b.c


示例16: main

int main() {
	int a[10];
	ScanArray(a, 10);
	MergeSort(a, 0, 9);
	PrintArray(a, 10);
	return 0;
}
开发者ID:kitianFresh,项目名称:DataStructStudy,代码行数:7,代码来源:MergeSort.c


示例17: MultiDeepModeTCDImageProcessThread

// ------------------------------------------------------------
// Description	:图像处理C模式线程
// Parameter	:void
// Retrun Value	:void
// ------------------------------------------------------------
void * MultiDeepModeTCDImageProcessThread(void*)
{
	LOGI( "MultiDeepModeTCD mode image thread is start here");
	//printf( "MultiDeepModeTCD mode image thread is start here\n");
	int nCnt = 0;

	//Color Frame
	int *pMultiDeepModeTCDFrameDisp = NULL;


	while (1)
	{
		//suspend check
		ThreadSpace::GetMultiDeepModeTCDImageThread()->SuspendCheck();

		//wait m_Sem_MultiDeepModeTCD
		SynSem::GetIDSem()->m_Sem_MultiDeepModeTCD.ConsumerWait();
		//get the cycle buffer
		int nRet = MultiDeepModeTCDFrameBuffer.GetReadPointer(&pMultiDeepModeTCDFrameDisp);
		if (0 == nRet)
		{
			LOGE("GetReadPointer failed in the GetMultiDeepModeTCD mode image thread!");
			//printf("GetReadPointer failed in the GetMultiDeepModeTCD mode image thread!\n");
		}
		//printf("显示\n");

		PrintArray(DEEP_POINTS,pMultiDeepModeTCDFrameDisp);

		SynSem::GetIDSem()->m_Sem_MultiDeepModeTCD.ConsumerDone();
        nCnt++;
		LOGI( "MultiDeepModeTCD mode image thread is done,%d",nCnt);

	}

}
开发者ID:lijundacom,项目名称:MyAndroidTCD,代码行数:40,代码来源:MultiDeepModeTCDThread.cpp


示例18: in

/**
 * @brief Returns the Json representation of a Json Object.
 */
std::string JsonProcessor::PrintObject (const JsonValueObject* value, const int indent_level)
{
    int il = indent_level + 1;
    std::string in (il * indent, ' ');
    std::stringstream ss;
    ss << "{";

    bool first = true;
    for (JsonValueObject::const_iterator it = value->cbegin(); it != value->cend(); ++it) {
        JsonValueObject::ObjectPair v = *it;
        if (!first) {
            ss << ",";
        }
        ss << "\n" << in << "\"" << v.first << "\": ";
        if (v.second->IsArray()) {
            ss << PrintArray(JsonValueToArray(v.second), il);
        } else if (v.second->IsObject()) {
            ss << PrintObject(JsonValueToObject(v.second), il);
        } else {
            ss << PrintValue(v.second);
        }
        first = false;
    }

    ss << "\n" << std::string(indent_level * indent, ' ') << "}";
    return ss.str();
}
开发者ID:daviddao,项目名称:genesis,代码行数:30,代码来源:json_processor.cpp


示例19: PrintTable

void Printer::PrintValue(std::string *result, Sqrat::Object object) {
	if (object.IsNull()) {
		result->append("null");
	} else {
		if (object.GetType() == OT_TABLE) {
			PrintTable(result, object.Cast<Sqrat::Table>());
		} else if (object.GetType() == OT_ARRAY) {
			PrintArray(result, object.Cast<Sqrat::Array>());
		} else if (object.GetType() == OT_INTEGER) {
			Util::SafeFormat(mPrintBuffer, sizeof(mPrintBuffer), "%lu",
					object.Cast<unsigned long>());
			result->append(mPrintBuffer);
		} else if (object.GetType() == OT_STRING) {
			result->append("\"" + object.Cast<std::string>() + "\"");
		} else if (object.GetType() == OT_BOOL) {
			result->append(object.Cast<bool>() ? "true" : "false");
		} else if (object.GetType() == OT_FLOAT) {
			Util::SafeFormat(mPrintBuffer, sizeof(mPrintBuffer), "%f",
					object.Cast<double>());
			result->append(mPrintBuffer);
		} else {
			Vector3 *vec3 = object.Cast<Vector3*>();
			if (vec3 != NULL) {
				Util::SafeFormat(mPrintBuffer, sizeof(mPrintBuffer),
						"Vector3(%f,%f,%f)", vec3->mX, vec3->mY, vec3->mZ);
				result->append(mPrintBuffer);
			}

		}
	}
}
开发者ID:kgrubb,项目名称:iceee,代码行数:31,代码来源:SquirrelObjects.cpp


示例20: main

int main() {
 Legendre leg(-1., 1., 8);
 DArray darr;
 leg.FindPolynomial(darr);
cerr << "Polynomial:";
PrintArray(darr);
 return 0;
}
开发者ID:vtsozik,项目名称:methods,代码行数:8,代码来源:legendre.cpp



注:本文中的PrintArray函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PrintAttribute函数代码示例发布时间:2022-05-30
下一篇:
C++ PrintAndLog函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap