Page 1 of 1

Modify using the following C program to write to read 10 car plate number and its color. Sort and store the data in a

Posted: Sat May 14, 2022 4:28 pm
by answerhappygod
Modify using the following C program to write to read 10
car plate number and its color. Sort and store the data in a
Single linked list in ascending way. Print out the data.
#include <stdlib.h>
#include <stdio.h>
struct snode{
int

pla;
char
st;
struct
snode *rrk;
struct
snode *llk;
};
struct snode *opt=0, *pt, *p1,*p2;
int main()
{
int i,p,s;
for(i=0;i<5;i++){
scanf("%d %c",&p,&s);
printf("%d %c\n",p,s);
pt=(struct snode
*)malloc(sizeof(struct snode));
if(opt==0){//the first
node
pt->pla=p;
pt->st=s;
opt=pt;
}
printf("plat=%d st=%c
\n",pt->pla, pt->st);
}
}