Snippets Collections
#include <stdio.h>
 
class Node
{
public:
    Node( int v )
    {
        data = v;
        left = 0;
        right = 0;
    }
 
    int data;
    Node* left;
    Node* right;
};
 
void Add( Node** root, Node* n )
{
    if ( !*root  )
    {
        *root = n;
        return;
    }
 
    if ( (*root)->data < n->data )
    {
        Add( &(*root)->right, n );
    }
    else
    {
        Add( &(*root)->left, n );
    }
}
 
void Print( Node* node )
{
    if ( !node )  return;   
    Print( node->left );
    printf( "value = %i\n", node->data );
    Print( node->right );
}
 
int main()
{
    Node* root = 0;
 
    Add( &root, new Node( 1 ) );
    Add( &root, new Node( 2 ) );
    Add( &root, new Node( -1 ) );
    Add( &root, new Node( 12 ) );
 
    Print( root );
    return 0;
}
int maxSubArraySum(int a[], int size) 
{ 
int max_so_far = 0, max_ending_here = 0; 
for (int i = 0; i < size; i++) 
{ 
	max_ending_here = max_ending_here + a[i]; 
	if (max_ending_here < 0) 
		max_ending_here = 0; 

	/* Do not compare for all elements. Compare only 
		when max_ending_here > 0 */
	else if (max_so_far < max_ending_here) 
		max_so_far = max_ending_here; 
} 
return max_so_far; 
} 
#include<iostream>                //including input/output libarary
using namespace std;
int main(){                               //starting main function
int array_name[5];                   //defining a variable array of type integer with name "array_name" and size 5.
array_name[0]=2;                   //assigning value of 2 to  first element of array "array_name"
array_name[1]=3;                   
array_name[2]=4                      // assinging values to other elements of array using their index number
array_name[3]=12;
array_name[4]=33;

return 0;
}
> More steps
// Define macros for inlining x86 assembly in a compiler-independent way
#ifdef _MSC_VER
	#define ASM1(asm_literal) \
		__asm asm_literal
	#define ASM2(asm_literal1, asm_literal2) \
		__asm asm_literal1, asm_literal2
	#define ASM3(asm_literal1, asm_literal2, asm_literal3) \
		__asm asm_literal1, asm_literal2, asm_literal3

	#define ASM_MOV_REG_VAR(register, variable) \
		ASM(mov register, variable)

	#define ASM_MOV_VAR_REG(variable, register) \
		ASM(mov variable, register)

#elif __GNUC__ || __clang__
	#define ASM1(asm_literal) \
		ASM_GCC(#asm_literal)
	#define ASM2(asm_literal1, asm_literal2) \
		ASM_GCC(#asm_literal1 ", " #asm_literal2)
	#define ASM3(asm_literal1, asm_literal2, asm_literal3) \
		ASM_GCC(#asm_literal1 ", " #asm_literal2 ", " #asm_literal3)
	
	#ifdef __x86_64__
		#define ASM_MOV_REG_VAR(register, variable) \
			__asm__ __volatile__("movq %0, %%" EXPAND_AND_QUOTE(register)  : /* no outputs */ : "m"(variable) : )

		#define ASM_MOV_VAR_REG(variable, register) \
			__asm__ __volatile__("movq %%" EXPAND_AND_QUOTE(register) ", %0"  : "=m"(variable) : /* no inputs */ : )
	#else
		#define ASM_MOV_REG_VAR(register, variable) \
			__asm__ __volatile__("mov %0, %%" EXPAND_AND_QUOTE(register)  : /* no outputs */ : "m"(variable) : )

		#define ASM_MOV_VAR_REG(variable, register) \
			__asm__ __volatile__("mov %%" EXPAND_AND_QUOTE(register) ", %0"  : "=m"(variable) : /* no inputs */ : )
	#endif

	#define ASM_GCC(asm_string) \
		__asm__ __volatile__(".intel_syntax noprefix;" asm_string ";.att_syntax prefix"); \
	
#endif
bookmark
dashboard

Fri Sep 11 2020 14:28:11 GMT+0000 (UTC) https://www.technical-recipes.com/2011/simple-binary-tree-implementation/

#c++
bookmark
dashboard

Thu Jul 16 2020 13:01:21 GMT+0000 (UTC) https://github.com/an-tao/drogon

#c++ #web #rest
bookmark
dashboard

Wed Dec 25 2019 10:57:06 GMT+0000 (UTC) https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/

#c++ #algorithms #interviewquestions #arrays
bookmark
dashboard

,

#c++

.

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension