操作系统
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> #define MAX 24 typedef struct partition{ char proname[10]; int begin; int size; char status; }node; node *Free,*used; void Outpu1() { printf("\n\n\n初始化 , 设内存总容量是512K\n"); printf("系统从低地址部分开始使用, 占用100K\n\n"); } main() { int i=0; printf("请输入程序的名字: "); Free=(node *)malloc(sizeof(node)); scanf("%s",Free->proname); printf("请输入起址: \n"); scanf("%d",&Free->begin); printf("长度: \n"); scanf("%d",&Free->size); Free->status='f'; i+=1; Outpu1(); printf("空闲区列表Free:\n"); printf("\tNO.\tproname\tbegin\tsize\tstatus\n"); printf("\t%d\t%s\t%d\t%d\t%c\n",i,Free->proname,Free->begin,Free->size,Free->status); used=Free; used->status='u'; used->begin=0; used->size=512-used->size; printf("空闲区列表Free:\n"); printf("\tNO.\tproname\tbegin\tsize\tstatus\n"); printf("\t%d\t%s\t%d\t%d\t%c\n",i,used->proname,used->begin,used->size,used->status); printf("内存使用情况,按起始址增长的排:: \n"); printf("printf sorted by address:: \n"); printf("\tNO.\tproname\tbegin\tsize\tstatus\n"); printf("--------------------------------------------\n"); printf("\t%d\t%s\t%d\t%d\t%c\n",i,Free->proname,Free->begin,Free->size,Free->status); printf("\t%d\t%s\t%d\t%d\t%c\n",i,used->proname,used->begin,used->size,used->status); }