题解 | #牛牛的单链表求和#
牛牛的单链表求和
https://www.nowcoder.com/practice/a674715b6b3845aca0d5009bc27380b5
#include <stdio.h> typedef struct Node{ int data; struct node* next; } node; node* cai(int v){ node* kk=(node*)malloc(sizeof(node)); kk->data=v; kk->next=NULL; return kk; } int main(){ int n; scanf("%d",&n); node* head=NULL; node* tail=NULL; int sum=0; for(int i=0;i<n;i++){ int t; scanf("%d",&t); node* f=cai(t); sum=sum+f->data; } printf("%d",sum); }