struct t_node *delete_first(struct t_node *head)
)。
#include <stdio.h>
#include <stdlib.h>
struct t_node {
int number;
struct t_node *next;
};
struct t_node * insert (struct t_node *head, int num){
struct t_node * new_node = malloc(sizeof(struct t_node));
new_node->number = num;
new_node->next = head;
return new_node;
}
void printlistvalues(struct t_node *head){
while (head != NULL){
printf("%d\n", head->number);
head = head->next;
}
}
struct t_node *delete_first(struct t_node *head){
struct t_node *help = head;
head = head->next;
free(help);
return head;
}
int main(){
struct t_node *list = NULL;
list = insert(list, 10);
list = insert(list, 20);
list = insert(list, 30);
list = insert(list, 40);
list = insert(list, 50);
printlistvalues(list);
printf("\n");
delete_first(list);
printlistvalues(list);
return 0;
}
答案 0 :(得分:2)
你必须写
def sum13(nums):
if 13 not in nums:
return sum(nums)
ret = 0
count_next = True
for num in nums:
if num == 13:
count_next = False
elif count_next:
ret += num
else:
count_next = True
return ret
此外,该功能本身应该是
list = delete_first(list);