/* Tim dia chi tai nut k */
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef int info_type;
struct node {
info_type info;
struct node *next;
struct node *priv;
} *first = NULL, *last = NULL;
void insert(info_type e)
{
struct node *tmp;
tmp = (struct node*) malloc(sizeof(struct node));
tmp->info = e;
tmp->next = NULL;
if (first == NULL)
first = last = tmp;
else
{
last->next = tmp;
last = last->next;
}
}
int main()
{
info_type e,x;
int k,d = 1;
struct node *p;
printf("\nNhap cac gia tri so (0) de ket thuc : \n");
do {
scanf("%d", &e);
if (e != 0)
insert(e);
} while (e != 0);
printf("Nhap vi tri k,(tim dia chi tai k): ");
scanf("%d", &k);
p = first;
while ( d <= k -1 )
{
p = p ->next;
d = d+1;
}
p->info = x;
printf("dia chi tai k la :");
scanf("%d", &x);
getch();
return k;
}
Bạn xem cái mình trích dẫn nhé. Nếu in ra thì người ta ko dùng scanf đâuprintf("dia chi tai k la :");
scanf("%d", &x);