Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * prog.c
- *
- * Created on: Nov 10, 2016
- * Author: dastan.iyembergen
- */
- #include <stdio.h>
- typedef struct _letter{
- char c;
- struct _letter *link;
- } letter;
- void printAZ(letter *f){
- if (f==NULL)
- return;
- printf("%c ", (*f).c);
- printAZ((*f).link);
- }
- void printZA(letter *fp){
- if (fp==NULL)
- return;
- printZA((*fp).link);
- printf("%c ", (*fp).c);
- }
- int main(void) {
- letter *first=NULL;
- letter *prev=NULL;
- int i;
- for (i=0; i<26; i++){
- letter *ch=(letter*)malloc(sizeof(letter));
- (*ch).c='a'+i;
- (*ch).link=NULL;
- if (first==NULL){
- first=ch;
- } else{
- (*prev).link=ch;
- }
- prev=ch;
- }
- printAZ(first);
- printf("\n");
- printZA(first);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment