Information such as "Memory access violation" or "segmentation violation" usually means that a pointer variable contains a pseudo-address. One common reason is that initializing a variable fails.
The result of free (p) is that the address to which P is pointing does not change, but the data at that address is undefined at this time.
Occasionally, when your program uses a lot of space, the system may not meet your requirements for the new unit. A null pointer is returned at this time.
Warning: malloc (sizeof (Ptrtonode)) is legal, but it does not allocate enough space to the struct. It assigns only one space to the pointer.
An array of size n, whose main element is an element that has more occurrences than N/2 (thus having at most one of these elements).
Program 1: Find the main elements of an array
#include <stdio.h> #define size 100int main () { int array[size],i,n,num[10]={0}; printf ("please input the array size : "); &NBSP;&NBSP;&NBSP;&NBSP;SCANF ("%d ", &n); printf (" Please input the array[%d] :\n ", n); for (i=0;i<n;++i) &NBSP;&NBSP;{&NBSP;SCANF ("%d", &array[i]); num[array[i]]++; } for (i=0;i<n;i++) { if (num[i]> (N/2)) { printf ("the mainelement is : %d\n", i); return 0; } } printf ("there is no mainelement!\n"); return 0;}
"Data structure and algorithm analysis--c language description" after reading note 2