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

C++ printArray函数代码示例

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

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



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


示例16: main

int main ()
{
	time_t current;
	time( & current );
	srand( ( unsigned int ) current );

	const int SIZE = 10;
	int data[ SIZE ];
	for ( int i = 0; i < SIZE; i++ )
		data[ i ] = i + 1;

	printArray( data, SIZE );

	randomShuffle( data, SIZE, 1 );

	printArray( data, SIZE );

	randomShuffle( data, SIZE );

	printArray( data, SIZE );

	return 0;
}
开发者ID:zaychenko-sergei,项目名称:cpp_intro,代码行数:23,代码来源:random_shuffle.cpp


示例17: main

int main(){
    const int arrSize = 10;
    int Arr1[arrSize] = { 1, 27, 89, 12, 78, 19, 0, 1, 12, 3};
    int Arr2[arrSize] = { 4, 13, 90, 90, 15, 13, 4, 5, 6, 12};
    //time_t start = time(NULL);
    std::thread thread1(bubbleSort, Arr1, arrSize);
    //thread1.join(); // sequential
    std::thread thread2(insertSort, Arr2, arrSize);
    std::thread threadP1(printArray, Arr1, arrSize);
    std::thread threadP2(printArray, Arr2, arrSize);
    std::cout << "ARRAYS READY\n";
    thread1.join();
    thread2.join();
    //time_t stop = time(NULL);
    threadP1.join();
    threadP2.join();
    //cout << "ELAPSED " << (stop - start) << "\n"
    std::cout << "Printing out the array without using threads "<< std::endl;
    printArray(Arr1, arrSize);
    std::cout << std::endl;
    printArray(Arr2, arrSize);
    return 0;
}
开发者ID:DzouOnionGardener,项目名称:OnionPP,代码行数:23,代码来源:concurrencyTest.cpp


示例18: tdesTest

void tdesTest()
{
  byte out[8];
  byte in[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
  byte key[] = { 
                  0x3b, 0x38, 0x98, 0x37, 0x15, 0x20, 0xf7, 0x5e, // key A
                  0x92, 0x2f, 0xb5, 0x10, 0xc7, 0x1f, 0x43, 0x6e, // key B
                  0x3b, 0x38, 0x98, 0x37, 0x15, 0x20, 0xf7, 0x5e, // key C (in this case A)
                };
  
  Serial.println();
  Serial.println("====== Triple-DES test ======");
  
  //encrypt
  Serial.print("Encrypt...");
  unsigned long time = micros();
  des.tripleEncrypt(out, in, key);
  time = micros() - time;
  Serial.print("done. (");
  Serial.print(time);
  Serial.println(" micros)");
  printArray(out);
  
  //decrypt
  for (int i = 0; i < 8; i++)
  {
    in[i] = out[i];
  }
  Serial.print("Decrypt...");
  time = micros();
  des.tripleDecrypt(out, in, key);
  time = micros() - time;
  Serial.print("done. (");
  Serial.print(time);
  Serial.println(" micros)");
  printArray(out);
}
开发者ID:fcgdam,项目名称:DES_Library,代码行数:37,代码来源:application.cpp


示例19: main

int main(int argc, char **argv) {

	int n;
	int a[N];
	int i, j;

	printf("Nhap vao so phan tu: ");
	scanf("%d", &n);

	printf("Nhap cac phan tu cua mang\n");
	for (i = 0; i < n; ++i) {

		printf("a[%d] = ", (i + 1));
		scanf("%d", &a[i]);
	}

	printf("Mang vua nhap la: ");
	printArray(a, n);

	for (j = 0; j < n; j++) {

		for (i = n - 1; i > j; i--) {

			if (a[i] < a[i - 1]) {

				int t = a[i];
				a[i] = a[i - 1];
				a[i - 1] = t;
			}
		}
	}

	printf("\nMang sau khi thuc hien thuat toan: ");
	printArray(a, n);

	return 0;
}
开发者ID:programmerit,项目名称:C-Tutorials,代码行数:37,代码来源:bubble_sort_array_2.c


示例20: threeBuckets

void threeBuckets(int *array, int length, int low, int high) {
	int i = 0;
	int lowIndex = 0;			// initial low pivot index
	int highIndex = length-1;	// initial high pivot index
	int temp = 0;

	for(i = 0; i < length; i++) {
		// when two pivot indices met
		if (lowIndex == highIndex) {
			break;
		}

		if (low < array[i]) {
			// swap(array, lowIndex+1, i);
			printf("low swap: ");
			printArray(array, length);
			temp = array[lowIndex+1];
			array[lowIndex+1] = array[i];
			array[i] = temp;
			printf("low swap: ");
			printArray(array, length);
			lowIndex++;
		}

		if (array[i] < high) {
			// swap(array, highIndex-1, i);
			printf("high swap: ");
			printArray(array, length);
			temp = array[highIndex-1];
			array[highIndex-1] = array[i];
			array[i] = temp;
			printf("high swap: ");
			printArray(array, length);
			highIndex--;
		}
	}
}
开发者ID:Junyong-Suh,项目名称:threeBuckets,代码行数:37,代码来源:threeBuckets.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ printCallSite函数代码示例发布时间:2022-05-30
下一篇:
C++ print2函数代码示例发布时间: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