Segment error (vomit) solution ~~ -- Linux general technology-Linux programming and kernel information. The following is a detailed description. # Include
# Include
Typedef struct
{
Int data [1000];
Int length;
} Lv;
Void su (lv * & l, int n)
{
Int I;
L-> length = 0;
L = (lv *) malloc (sizeof (lv ));
For (I = 0; I
{
Scanf ("% d", & l-> data );
L-> length ++;
}
}
Int md (int item, lv * l)
{
Int I = 0;
While (I Length & l-> data ! = Item)
{
I ++;
}
If (I> l-> length)
{
Return 0;
}
Else
{
Return I + 1;
}
}
Int main ()
{
Lv * l;
Int k, item, p, n;
Scanf ("% d", & n );
Su (l, n );
Scanf ("% d", & item, & p );
K = md (item, l );
If (k = 0)
{
L-> data [n] = p;
}
Else
{
Int I;
For (I = n; I> = k; I --)
{
L-> data= L-> data [i-1];
}
L-> data [k] = p;
}
Int q = 0;
While (q <= n)
{
If (q = n)
{
Printf ("% d \ n", l-> data [q]);
}
Else
{
Printf ("% d", l-> data [q]);
}
Q ++;
}
Free (l );
Return 0;
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service