A C programming problem 20

Updated on technology 2024-05-04
4 answers
  1. Anonymous users2024-02-09

    Is it called 0th or 1st position next to s2? This is better explained.

    Function: Insert the character linked list t after the ith element of the character linked list s.

    The index of a linked list element starts at 0.

    void insert(str s, str t, int i)str temp1;

    while(i != 0)

    s = s->next;

    if(null == s)return;

    i--;temp1 = s->next;In this case, you need to insert t t after s, and record the original content after s.

    str temp2 = t;Record t.

    while(t->next != null) to the tail of t.

    t = t->next;

    t = temp1;Attach the original content behind s to the back of t.

    s->next = temp2;Insert t.

    The new C standard allows variables to be declared in the middle of functions.

  2. Anonymous users2024-02-08

    Variables cannot be defined during function runtime. str temp2=t;You put this statement at the beginning of the function.

    while(i!=1){s=s->next;

    i--;You run like this and it's completely disrupted. It's best to save it before using it. Return when you run out.

  3. Anonymous users2024-02-07

    C does not support defining variables in the middle of a function, so be sure to put the statement defining the variable at the beginning of the function.

  4. Anonymous users2024-02-06

    Can I remove the head pointer like this? This linked list ......

    typedef struct node{

    char data;

    struct node *next;

    l,* str;

    str insert(str s,str t,int i)str temp1,temp2;

    temp1=s;

    while(i!=1)

    temp1=temp1->next;

    i--;temp2=temp1->next;

    temp1->next=t;

    while(t->next)

    t=t->next;

    t->next=temp2;

    return s;

Related questions
4 answers2024-05-04

First determine whether the year is a leap year (divisible by 4) according to the number of years, and then determine which array to use: >>>More

8 answers2024-05-04

It's nonsense to say so much above. Landlord please see: pay attention to your program: printf("%d,%d",(a,b),(b,a); >>>More

6 answers2024-05-04

The p of both is a pointer.

p=&t, change the content that p points to to the address of t, and p=&t is the address that changes the pointer to t. >>>More

7 answers2024-05-04

#include

void main() >>>More