求助,全部RE
查看原帖
求助,全部RE
566549
thezmmm楼主2021/11/1 21:20
#include<stdio.h>
#include<stdlib.h>

struct node{
    int value;
    int index;
    struct node *next;
};

int main(){
    int n,number = 0;
    scanf("%d",&n);
    struct node *head;
    head -> next = NULL;
    struct node *p;
    struct node *q;
    p = (struct node*)malloc(sizeof(struct node));
    q = (struct node*)malloc(sizeof(struct node));
    for(int i = 0;i < n;i++){
        scanf("%d",&number);
        p->next = NULL;
        p->value = number;
        p->index = i+1;
        if(head == NULL)
            head = p;
        else
            q->next = p;
        q = p;
    }
    struct node *t;
    struct node *m;
	t = head;
	while(t!=NULL){
        int flag = 0;
		m = t->next;
        while(m!=NULL){
            if(m->value > t ->value)
            {
                flag = 1;
                printf("%d ",m->index);
                break;
            }
            m = m->next;
        }
        if(flag == 0) printf("0 ");
		t = t->next;
	}
    return 0;
}
2021/11/1 21:20
加载中...