In string S, the Child string whose length is Len is obtained from position I. The function returns the child string chain table.

Source: Internet
Author: User

/*
Known strings use a chained storage structure with knots (For details, refer to linksrting. h file ),
Please write the function linkstring substring (linkstring S, int I, int Len ),
In string S, the Child string whose length is Len is obtained from position I. The function returns the child string chain table.
*/

# Include "linkstring. H"
/* Complete and test the function */
Linkstring substring (linkstring S, int I, int Len)
{
Linkstring temp;
Int J;
For (j = 0; j <I-1; j ++ ){
S = s-> next;
}
Temp = s;
While (Len --)
{
Temp = temp-> next;
}
Temp-> next = NULL;
Return S;
}
Int main ()
{Linkstring str1, str2;
Str1 = creat ();/* Create a string linked list */
Print (str1 );
Str2 = substring (str1, 3, 5);/* test, obtain the substring with a length of 5 from the first position. Please construct different test cases by yourself */
Print (str2);/* output substring */
Dellist (str1 );
Dellist (str2 );
Return 0;
}

In string S, the Child string whose length is Len is obtained from position I. The function returns the child string chain table.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.