Struktur Data : Ubah Infix Menjadi Postfix

//NAMA : Riyn Winesdyo W
//NIM : 1701292866
//KELAS: 02PPT

#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#define MAX 100

typedef struct stack
{
 int data[MAX];
 int top;
}stack;

int priority(char);
void init(stack *);
int empty(stack *);
int full(stack *);
char pop(stack *);
void push(stack *,char);
char top(stack *);

void main()
{
stack s;
char x;
int token;
init(&s);
clrscr();
printf("nEnter infix expression:");
  while((token=getchar())!='n')
  {
    if(isalnum(token))
       printf("%c",token);
    else
       if(token == '(')
           push(&s,'(');
       else
       {
         if(token == ')')
             while((x=pop(&s))!='(')
             printf("%c",x);
         else
         {
         while(priority(token)top=-1;
}
//---------------------------------------------
int empty(stack *s)
{
    if(s->top==-1)
 return(1);
    else 
 return(0);
}
//---------------------------------------------
int full(stack *s)
{
    if(s->top==MAX-1)
 return(1);
    else 
 return(0);
}
//---------------------------------------------
void push(stack *s,char x)
{
  s->top=s->top+1;
  s->data[s->top]=x;
}
//---------------------------------------------
char pop(stack *s)
{
   int x;
   x=s->data[s->top];
   s->top=s->top-1;
   return(x);
}
//---------------------------------------------
char top(stack * s)
{
   return(s->data[s->top]);
}
//---------------------------------------------

Struktur Data : Doubly Linked List

NAMA : Riyn Winesdyo W.
NIM : 1701292866
KELAS : 32PPT

#include <stdio.h>
#include <stdlib.h>

struct tnode{
	int data;
	struct tnode *next;
	struct tnode *prev;
}*node;

void print(){
	if(node!=0){
		while(node->next!=0){
			printf("%d ",node->data);
			node=node->next;
			}printf("%d",node->data);
	}

	printf("\n");
}

int main(){
	struct tnode *head = 0;
	struct tnode *tail = 0;
	struct tnode *newNode=0;
	//1
	head=(struct tnode*)malloc(sizeof(struct tnode));
	head->data=1;
	head->next=NULL;
	head->prev=NULL;
	node=head;
	tail=head;
	//3
	node->next=(struct tnode*)malloc(sizeof(struct tnode));
	node=node->next;
	node->data=3;
	node->next=NULL;
	node->prev=head;
	tail=node;

	node=head;
	print();
	//add number 2 between 1 and 3
	newNode=(struct tnode*)malloc(sizeof(struct tnode));
	node=newNode;
	newNode->data=2;
	node->prev=head;
	node->next=tail;
	head->next=node;
	tail->prev=node;
	

	node=head;
	print();
	//add 0 before 1
	newNode=(struct tnode*)malloc(sizeof(struct tnode));
	node=head;
	head=newNode;
	head->data=0;
	head->prev=NULL;
	head->next=node;
	
	node=head;
	print();
	//add 5 after 3
	newNode=(struct tnode*)malloc(sizeof(struct tnode));
	node=tail;
	tail=newNode;
	tail->data=5;
	tail->prev=node;
	tail->next=NULL;
	node->next=tail;
	
	node=head;
	print();

	getchar();
	return 0;
}

Tugas Struktur Data : Single Linked list

NAMA: Riyn Winesdyo Winarko
NIM : 1701292866
Kelas: 02PPT

#include
#include

struct node{
int x;
struct node *next;
};

int main(){
struct node *root;
struct node *conductor;

int jum=0;

root=(struct node*)malloc(sizeof(struct node));
root->next=0;
do{
printf(“Masukkan Angka[1..100] : “);
scanf(“%d”, &root->x);
fflush(stdin);
}while(root->xx>100);

jum++;

while(jumx);

while(conductor->next!=0){
conductor=conductor->next;
printf(“-> %d”, conductor->x);
}

if(jum==10){break;}

conductor->next=(struct node*)malloc(sizeof(struct node));
conductor=conductor->next;
conductor->next=0;
printf(“\n”);

do{
printf(“Masukkan Angka[1..100] : “);
scanf(“%d”, &conductor->x);
fflush(stdin);
}while(conductor->xx>100);
jum++;

}

getchar();
return 0;
}

jawaban tugas 1