2023-11-28 11:39来源:m.sf1369.com作者:宇宇
书写顺序
数据段定义DSEG
堆栈段定义SSEG
代码段定义CSEG
附加段定义
其中 代码段是程序主体 有很强的逻辑结构 SSEG DSEG是物理存储 就是数据在内存中的位置
汇编语言是直接对CPU说话的 也就是直接对CPU进行操作 一般的汇编语言都是基于某种CPU的 多数为80X86的 因为规范利于教学
// Queue.cpp : Defines the entry point for the console application.
//
#include stdafx.h
#include #include #define MAXQSIZE 10 typedef int QElemType; typedef struct{ QElemType *base; int front; int rear; }SqQueue;//你把这个struct分开就是你想要的了,我这里没有环境测试不了,你自己去测试吧 int InitQueue(SqQueue &Q){ Q.base = (QElemType *)malloc(MAXQSIZE * sizeof(SqQueue)); if(!Q.base){ printf(overflow\n); return 0; } Q.front = Q.rear = 0; return 1; } int EnQueue(SqQueue &Q, QElemType e){ if((Q.rear + 1) % MAXQSIZE == Q.front){ printf(queue is full\n); return 0; } Q.base[Q.rear] = e; Q.rear = (Q.rear + 1) % MAXQSIZE; return 1; } int DeQueue(SqQueue &Q, QElemType &e){ if(Q.rear == Q.front){ printf(queue is empty\n); return 0; } e = Q.base[Q.front]; Q.front = (Q.front + 1) % MAXQSIZE; return 1; } int GetHead(SqQueue &Q, QElemType &e){ if(Q.rear == Q.front){ printf(queue is empty\n); return 0; } e = Q.base[Q.front]; return 1; } int QueueLength(SqQueue &Q){ return ((Q.rear + MAXQSIZE) - Q.front) % MAXQSIZE; } bool QueueEmpty(SqQueue &Q){ return (Q.rear == Q.front); } void QueueTraverse(SqQueue &Q){ int i = Q.front; while(i != Q.rear) { printf(%d: %d \n, i, Q.base[i]); i = (i + 1) % MAXQSIZE; } } int main(int argc, char* argv[]) { SqQueue Q; InitQueue(Q); for(int i = 0; i < 7; i++) { EnQueue(Q, i); } QueueTraverse(Q); int e; for( i = 0; i < 5; i++) { DeQueue(Q, e); printf(%d , e); } printf(\n); for( i = 7; i < 15; i++) { EnQueue(Q, i); } QueueTraverse(Q); printf(length = %d\n, QueueLength(Q) ); return 0; }
#include#include #include typedef struct student { int ID; double score[5]; double Average; struct student *next; }Student , *pStudent; int Enter_score(char* filename , pStudent* pHead)//文件信息到链表 { FILE *fp; int number=1; char stu_score[256]; pStudent pCur , pTail; pTail =* pHead = (pStudent)malloc(sizeof(Student)); memset(*pHead , 0 ,sizeof(Student)); fp = fopen(filename , r); if(fp == NULL) { perror(fopen); return 0; } while(fgets(stu_score , 256 , fp)) { pCur = (pStudent)malloc(sizeof(Student)); memset(pCur , 0 ,sizeof(Student)); pCur->ID=number; number++; sscanf(stu_score,%lf%lf%lf%lf%lf,&pCur->score[0],&pCur->score[1],&pCur->score[2],&pCur->score[3],&pCur->score[4]); pCur->Average=(pCur->score[0]+pCur->score[1]+pCur->score[2]+pCur->score[3]+pCur->score[4])/5; pTail->next = pCur; pTail = pCur; } fclose(fp); return number; } void print_score(char* Entername , pStudent pHead , int len)//链表写入 文本{ pStudent pCur; pCur=pHead->next; FILE *fp; len--; fp = fopen(Entername , w); if(fp == NULL) { perror(fopen); return ; } while(pCur) { fprintf(fp,ID:%d score%.3f\t%.3f\t%.3f\t%.3f\t%.3f\tAverage: %.3f <-number:%d\n , pCur->ID,pCur->score[0] , pCur->score[1] , pCur->score[2] , pCur->score[3] , pCur->score[4] , pCur->Average,len--); pCur = pCur->next; } fclose(fp); }