当前位置: 首页>>代码示例>>C++>>正文


C++ printArray函数代码示例

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


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

示例1: main

int main()
{
    int arr[100];
    int n,i;
    printf("Enter Size:");
    scanf("%d",&n);
    printf("Enter the elements:");
    for(i=0;i<n;i++)
	scanf("%d",&arr[i]);
    quickSort(arr, 0, n-1);
    printf("Sorted array: \n");
    printArray(arr, n);
    return 0;
}
开发者ID:zaid09,项目名称:algorithms,代码行数:14,代码来源:quickSort.c

示例2: main

int main(void)
{
	int Input [] = {3,0,1};
	int Input_size = sizeof(Input)/sizeof(int);

	printf("Input array:\n");
	printArray(Input, Input_size);

	int missedNum = missingNumber(Input, Input_size);
	
	printf("The missed number is: %d\n", missedNum);

	return 0;
}
开发者ID:victor0623,项目名称:victor_leetcode,代码行数:14,代码来源:main.c

示例3: main

int main(void)
{
	int array [NUM][NUM];
	int i,j;
	for(i=0; i<NUM; i++)
	{
		for(j=0; j<NUM; j++)
		{
			array[i][j] = i*NUM + j;
		}
	}

	printArray(array);
}
开发者ID:hkiang01,项目名称:dailyprogrammer,代码行数:14,代码来源:test.cpp

示例4: main

int main() {
Vector dynamArray; //initialize the Dynamic array
vector_init(&dynamArray);

//user can make following input:
// - add to array eg. "1" then request for data to add
// - list all elements eg. "2"
// - check capacity eg. "3" 
// - check second highest element ex. "4"
// - exit the program with exit key ex. "5"
int input;
int numToAppend = 0; //number to append to the array
int loop = 0; //loop continues while loop is 0

while(loop == 0){
	
	printf("What would you like to do?\n");
	printf("Press:\n '1' to add to the array\n '2' to list all elements,\n '3' to check array capacity,\n '4' to find the second highest element,\n '5' to exit the program\n");
	scanf("%d", &input);
	switch (input) {
		case 1:
			printf("What would you like to add to array?\n");
			scanf("%d", &numToAppend);
			vector_append(&dynamArray, numToAppend);
			break;
		case 2:
			printArray(&dynamArray);
			break;
		case 3:
			printf("Current capacity of the array is ");
			printCapacity(&dynamArray);
			break;
		case 4:
			printf("The second highest element in the array is %d\n", findSecondHighest(&dynamArray));
			break;
		case 5:
			printf("Quitting program now.\n");
			loop = 1;
			break;
		default:
			printf("Incorrect input, try again\n");
			break;
		}
			
}


vector_free(&dynamArray); //free at the end of the program
return 0;
}
开发者ID:mikrou,项目名称:mikaelr.ca,代码行数:50,代码来源:DynamArray.c

示例5: main

//测试用例
void main()
{
 int list[20];           //存储输入的数据
 int index;              //保存输入的数据的长度
 int node;               //临时存储输入的数据
 printf("\n please input the values you want to sort[exit for 0]\n");
 index = 0;
 scanf("%d",&node);      //给node赋值

 while (node != 0)
 {
   list[index] = node;    //通过node给数据赋值
   index++;
   scanf("%d",&node);
 }
 printf("排序前:\n");

 printArray(list,index);  //打印排序前的状态
 shellSort(list,index);  //进行排序
 printf("\n排序后:\n");  
 printArray(list,index);   //打印排序后的状态
 system("pause");
}
开发者ID:chenchaohui,项目名称:CPlusPlus,代码行数:24,代码来源:main.c

示例6: main

int main()
{
    int *array = randArray(SORTCOUNT, 1000);
    printArray(array, SORTCOUNT, 0);
/*
    bubbleSort(array, SORTCOUNT);
    printArray(array, SORTCOUNT, 1);
    insertSort(array, SORTCOUNT);
    printArray(array, SORTCOUNT, 1);
    shellSort(array, SORTCOUNT);
    printArray(array, SORTCOUNT, 1);
    quickSort(array, SORTCOUNT);
    printArray(array, SORTCOUNT, 1);
    selectionSort(array, SORTCOUNT);
    printArray(array, SORTCOUNT, 1);
*/
    mergeSort(array, SORTCOUNT);
    printArray(array, SORTCOUNT, 1);


    free(array);
    return 0;
}
开发者ID:wangsingx,项目名称:sort,代码行数:23,代码来源:sort.c

示例7: main

int main()
{
  int array[MAX];
  int max;

  getNums(array);
  max = computeMax(array);

  printArray(array);

  printf("Max is %d\n", max);

  return 0;
}
开发者ID:Manouchehri,项目名称:comp2401,代码行数:14,代码来源:example4.c

示例8: PrintAllPathExists

void PrintAllPathExists(tree_node *root, int *paths, int level, int sum){
	if(root == NULL) return;
	paths[level] = root->data;
	int i = level, tmp_sum = 0;
	for(; i>= 0; i--){
		tmp_sum += paths[i];
		if(tmp_sum == sum){
			printArray(paths, sum, i, level);
		}
	}
	level++;
	PrintAllPathExists(root->left, paths, level, sum);
	PrintAllPathExists(root->right, paths, level, sum);
}
开发者ID:satish2,项目名称:Learn,代码行数:14,代码来源:AllBinaryTree.c

示例9: main

int main()
{
    int arr[] = {1, 2, 3, 4, 5, 6};
    int n = sizeof(arr)/sizeof(arr[0]);

    int d = 2;
    //scanf("%d", &d);

    //rotateLeft(arr, n, d);
    rotateRight(arr, n, d);

    printArray(arr, n);
    return 0;
}
开发者ID:amit-upadhyay-IT,项目名称:probable-octo-disco,代码行数:14,代码来源:19_2.c

示例10: printAll

void printAll(struct tree *root,int path[],int pathLen)
{
	if(root==NULL) return;
	path[pathLen]=root->data;
	pathLen++;
	if(root->left == NULL && root->right==NULL)
		printArray(path,pathLen);
	else
	{
		printAll(root->left,path,pathLen);
		printAll(root->right,path,pathLen);
	}

}
开发者ID:JavaInCloud,项目名称:Algorithms,代码行数:14,代码来源:binarytree.cpp

示例11: AdjacencyMatrix

void AdjacencyMatrix(int a[][100], int n){
    int i,j;
    for(i = 0;i < n; i++)
    {
        for(j = 0;j < i; j++)
        {
            a[i][j] = a[j][i]= rand()%50;
            if( a[i][j]>40)a[i][j]=a[j][i]=999;
             
        }
    a[i][i] = 999;
    }
    printArray(a,n);
}
开发者ID:vijeenroshpw,项目名称:Datastructures_Lab,代码行数:14,代码来源:kruskal.c

示例12: main

// function main
int main()
{
	int array[5] = {1, 2, 3, 4 ,5};
	int i = 0; 
	int len = 5;
	// print the orignal array
	for (i = 0; i < len; i++) {
		printArray(array, len);

	    // mapped by twice
		map(array, len, twice);
	}
	return 0;
}
开发者ID:IndexXuan,项目名称:V-2-V5,代码行数:15,代码来源:high-level-function.c

示例13: main

main()
{
    int N = 8, maxSum = 0;    
    char p[256];
    char *str = p;
    ElementType A[] = {4, -3, 5, -2, -1, 2, 6, -2};

    printf("\t ========== [third method-devide and conquer] test for maximum sum of subsequence ==========\n\n");
    str = "initial array A: ";
    printf("%50s",str);
    printArray(A, N);    

    str = "after computing maximum sum of subsequence: ";
    printf("%50s", str);
    maxSum = maxSubsequenceSum(A, 0, N-1);
    printArray(A, N);

    str = "maximum sum of array subsequence is: ";
    printf("%50s", str);
    printf("%4d\n\n", maxSum);

    return 0;
}
开发者ID:pacosonTang,项目名称:dataStructure-algorithmAnalysis,代码行数:23,代码来源:p20.c

示例14: main

int main(int argc, const char * argv[]) {
    int size, k, val, valAfterSorting;
    int * arr;
    
    for(size = 1; size < 11; size++) {
        arr = createRandomArray(size);
        printArray(arr, size);
        
        k = randMinMax(0, size-1);
        val = selectKthOrder(arr, 0, size-1, k);
        printArray(arr, size);
        printf("k: %d, val: %d\n", k, val);
        
        quickSort(arr,0, size-1);
        valAfterSorting = arr[k];
        printArray(arr, size);
        printf("arr[k]: %d\n", valAfterSorting);
        printf("isSame: %d\n", isSame(val, valAfterSorting));
        free(arr);
        printf("-------------------------------------\n");
    }
    return 0;
}
开发者ID:KimDahye,项目名称:2014-03-DS-Algorithm2,代码行数:23,代码来源:selectKthOrder.c

示例15: printArray

void printArray(std::ostream& o, cpptoml::array& arr) {
    o << "{\"type\":\"array\",\"value\":[";
    auto it = arr.get().begin();
    while (it != arr.get().end()) {
        if ((*it)->is_array())
            printArray(o, *(*it)->as_array());
        else
            printValue(o, *it);
        
        if (++it != arr.get().end())
            o << ", ";
    }
    o << "]}";
}
开发者ID:cran,项目名称:RcppTOML,代码行数:14,代码来源:parse.cpp


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