- 博客(0)
- 资源 (3)
空空如也
编译原理 词法分析(内有源代码)
#include<string.h>
char ch;
#define ID 100;
#define I 20;
char token[20];
int d=0;
//int i=0;
bool isanum(char ch);
bool isaabc(char ch);
void scanner_exam(FILE *f);
struct option{
int Class;
char* value;
int address;
char f[20];
}s[1000];
struct fuhao{
char* name;
}biao[1000];
void main()
{
char fname[20];
FILE *fp;
do{
printf("Input the filename:");
scanf("%s",fname);
fp = fopen(fname,"r");
}while(!fp);
scanner_exam(fp);
fclose(fp);
}
int lookup(char* t){
if(strcmp(t,"main")==0)
return 1;
2012-04-25
操作系统(FIFO,LRU算法,内有用栈编写的源代码)
typedef struct
{
datatype data[1024];
int top;
int pop;
}seqstack;
/**** 空栈 *****/
void SETNULL(seqstack *s)
{
s->top=-1;
s->pop=-1;
}
/**** 入栈 *****/
void PUSH(seqstack *s,datatype x,int nc_size)
{
if(s->top==nc_size-1)
{
s->pop++;
s->data[s->pop]=x;
}
else
{
s->top++;
s->data[s->top]=x;
}
}
/**** 栈空 *****/
int EMPTY(seqstack *s)
{
if(s->top>=0)return 0;
else return 1;
}
/**** 用于LRU入栈 *****/
void PUSH1(seqstack *s,datatype x,int nc_size){
// s->pop++;
while(s->poppop++;
if(s->data[s->pop]==x){
for(int i=s->pop;idata[i]=s->data[i+1];
}
}
}
s->data[s->top]=x;
}
/**** 判断 *****/
int FULL(seqstack *s,int nc_size)
{
if(s->top==nc_size-1)return 1;
else return 0;
}
/**** 压栈 *****/
void POP(seqstack *s,int nc_size)
{
if(EMPTY(s))
{}
else
{
for(int i=0;idata[i]=s->data[i+1];
s->top--;
}
}
void showzhan(seqstack *s,int nc_size){
for(int k=nc_size-1;k>=0;k--){
cout<<"栈队列----------------------[ "<data[k]<<"]"<<endl;
}
}
2012-04-25
操作系统(最佳算法实验加进程控制)
操作系统,最佳算法
部分代码 for (int i = 0; i != 5; ++i)
{
struct PCB *p = (struct PCB*)malloc(sizeof(struct PCB));
printf("进程号No.%d:\n", i);
printf("输入进程名:");
scanf("%s", p->p_name);
printf("输入进程运行时间:");
scanf("%d", &p->p_needTime);
p->p_runTime = 0;
p->p_state = 'W';
p->next = NULL;
pt->next = p;
pt = p;
printf("\n\n");
}
getchar(); //接受回车
//processes作为头结点来存储链表
processes = processes->next;
int cases = 0;
while (1)
{
++cases;
pt = processes;
printf("The execute number: %d\n\n", cases);
printf("**** 当前正在运行的进程是:%s\n", pt->p_name);
pt->p_state = 'R';
printf("qname state super ndtime runtime\n");
printf("%s\t%c\t%d\t%d\t%d\t\n\n", pt->p_name, pt->p_state, pt->p_priority, pt->p_needTime, pt->p_runTime);
pt->p_state = 'W';
pt->p_runTime++;
pt->p_priority--;
printf("**** 当前就绪状态的队列为:\n\n");
pt = pt->next;
while (pt != NULL)
{
2012-04-06
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人