# 丑数（栈和队列）

6

YES

``8``

``YES``

``````#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define  maxsize 100
typedef struct node
{
int data;
struct node *next;
}lnode;
{
s->data=ch;
s->next=NULL;
if(rear==NULL)
front=s;
else
rear->next=s;
rear=s;
}
int outqueue()
{
int temp;
if(front!=NULL)
{
top=front;
front=front->next;
temp=top->data;
free(top);
return temp;
}
else
return -1;
}
int main()
{
int flag=0,n;
scanf("%d",&n);
while(n%2==0)
{
n/=2;
}
while(n%3==0)
{
n/=3;
}
while(n%5==0)
{
n/=5;
}
while(front!=NULL)
{
n=outqueue();
if(n!=2&&n!=3&&n!=5&&n!=1&&n!=0)
flag=1;
}
if(flag)
printf("NO\n");
else
printf("YES\n");
return 0;
} ``````

``````#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define  maxsize 100
typedef struct node
{
int data;
struct node *next;
}lnode;
{
s->data=ch;
s->next=NULL;
if(rear==NULL)
front=s;
else
rear->next=s;
rear=s;
}
int outqueue()
{
int temp;
if(front!=NULL)
{
top=front;
front=front->next;
temp=top->data;
free(top);
return temp;
}
else
return -1;
}
int main()
{
int flag=0,n;
scanf("%d",&n);
while(n%2==0)
{
n/=2;
}
while(n%3==0)
{
n/=3;
}
while(n%5==0)
{
n/=5;
}
while(front!=NULL)
{
n=outqueue();
if(n!=2&&n!=3&&n!=5&&n!=1&&n!=0)
flag=1;
}
if(flag)
printf("NO\n");
else
printf("YES\n");
return 0;
} ``````