各位c语言高手!求帮助!求c语言编程答案!急!题目在纸上!全英文的!

2024-12-25 12:25:41
推荐回答(3个)
回答1:

看不太清楚也就算了 还特么的是英文的....

回答2:

#include 
#include
int length(char *str)
{
    int i = 0;
    if (!str)
        return 0;
    while(str[i++] != '\0');
    return i - 1;
}
int reverse(char src[], char dest[])
{
    int len = 0;
    int i = 0;
    int j = 0;
    if (!src)
        return -1;
    len = length(src);
    while(src[i] != '\0') {
        dest[len - (j++) - 1] = src[i++];
    }
    dest[len] = '\0';
    return 0;
}
typedef struct _node {
    int data;
    struct _node *next;
}*Link_list;
int list_length(Link_list head)
{
    int i = 0;
    Link_list p;
    if (!head)
        return 0;
    p = head;
    while(p->next) {
        i++;
        p = p->next;
    }
    return i;
}
int reverse_list(Link_list head)
{
    Link_list p, q;
    Link_list new;
    if (!head)
        return 0;
    new = malloc(sizeof(struct _node));
    if(!new)
        return 0;
    new->next = NULL;
    p = head;
    while((q = p->next)) {
        head->next = q->next; // remove from the orig list.
        q->next = new->next;        // add into the new head list.
        new->next = q;
           
        p = head;
    }
    head->next = new->next;
    free(new);
    return 0;
}
Link_list head = NULL;
int init_list(void)
{
    Link_list p;
    int i;
    head = malloc(sizeof(struct _node));
       
    head->next = NULL;
    for(i = 0; i <10; i ++)
    {
        p= malloc(sizeof(struct _node));
        p->data = i;
        p->next = NULL;
        p->next = head->next;
        head->next = p;
    }
    return 0;
}
int disp_list(Link_list head)
{
    Link_list p;
    int i;
    p = head->next;
    while(p) {
        printf("%d ", p->data);
        p = p->next;
    }
}
int main()
{
    char *str = "abcdeee";
    char dest[256] = {0};
    printf("Length of str: %d\n", length(str));
    reverse(str, dest);
    printf("After reverse: %s\n", dest);
    init_list();
    printf("after init\n");
    disp_list(head);
    printf("disp  list 1\n");
    reverse_list(head);
    printf("disp  list 2\n");
    disp_list(head);
       
    return 0;
}
完整答案!

回答3:

4.8寸屏幕表示只看家一格一格的像素。建议以后提问把它打出来,这样也会加深一下楼主的印象,便于理解。