DESProcess FILE *mfp,*cfp int ttch=0,xorRes,ttbitdiff=0 char mch,cch float bdiff=0 if((mfp=fopen(mfile,"r"))==NULL) {cout<<"Cannot open the file to compare"<<endl } if((cfp=fopen(cfile,"r"))==NULL) {cout<<"Cannot open the file to compare"<<endl } else { while(!feof(mfp)&!feof(cfp)) { ttch++ mch=fgetc(mfp) cch=fgetc(cfp) xorRes=mch^cch ttbitdiff+=(xorRes&1)+(xorRes&2)/2+(xorRes&4)/4+(xorRes&8)/8+(xorRes&16)/16+(xorRes&32)/32+(xorRes&64)/64+(xorRes&128)/128 } bdiff=float(ttbitdiff)*100/float(ttch*8) } *bitdiff8byte=float(ttbitdiff)*100/float(8*8) return bdiff
標(biāo)簽: DESProcess ttbitdiff xorRes bdiff
上傳時(shí)間: 2016-07-02
上傳用戶:1079836864
4bit ALU(運(yùn)算邏輯單元)的設(shè)計(jì) 給出了此次設(shè)計(jì)alu的輸入輸出結(jié)構(gòu)及相應(yīng)的位數(shù)。其中C0是一位的進(jìn)位輸入,A和B分別是4位的數(shù)據(jù)輸入,S0、S1、M分別為一位的功能選擇輸入信號(hào);cout是一位的進(jìn)位輸出,F(xiàn)是4為的運(yùn)算結(jié)果輸出。
標(biāo)簽: 4bit ALU alu 運(yùn)算
上傳時(shí)間: 2013-12-09
上傳用戶:sevenbestfei
一個(gè)日志類程序。平時(shí)寫(xiě)程序時(shí)經(jīng)常要記錄下日志,C++的cout類很好用吧,呵呵,以前寫(xiě)了個(gè)類似的類 來(lái)記錄下程序的運(yùn)行日志。
上傳時(shí)間: 2013-12-29
上傳用戶:aix008
SSD5_EXE3練習(xí)題 if (!testConstructors()) { cerr << "Constructor and\\or accessors failed check\n" return EXIT_FAILURE } if (!testLessThan()) { cerr << "Operator < failed check\n" return EXIT_FAILURE } if (!testInsertion()) { cerr << "Operator >> failed check\n" return EXIT_FAILURE } cout << "All tests passed\n" return EXIT_SUCCESS
標(biāo)簽: testConstructors Constructor accessors failed
上傳時(shí)間: 2016-11-16
上傳用戶:zhliu007
(1) 計(jì)數(shù)器的輸入為RST(復(fù)位),EN(使能),CLK(時(shí)鐘),U_D(up_down加/減選擇);輸出為cout(進(jìn)位/借位輸出),CQ(3:1)(數(shù)值輸出); 范圍65536。
標(biāo)簽: RST 計(jì)數(shù)器 復(fù)位 輸入
上傳時(shí)間: 2014-08-12
上傳用戶:lizhizheng88
#include <iostream> using namespace std; int main(){ int t; cin>>t; while(t--){ long long n; cin>>n; if(n%2==1) cout<<(n*n-1)/4<<endl; else if (n%4==0) cout <<(n*n)/4-1<<endl; else{ if(n==2) cout<<1<<endl; else{ long long k=n/2-1; cout <<k*k+2*k-3<<endl; } } } return 0; }
標(biāo)簽: 天津大學(xué)acm4022 代碼
上傳時(shí)間: 2015-04-20
上傳用戶:nr607
#include <iostream> using namespace std; class Student { public: Student(int, int); int num; int grade; }; Student::Student(int n, int g) { num = n; grade = g; } int maxGradeIndex(Student* s) { int maxGrade, index = 0, i = 0; maxGrade = s[0].grade; for (i = 0; i<5; i++) { if (s[i].grade > maxGrade) { maxGrade = s[i].grade; index = i; } } return index; } int main() { Student a[5] = { Student(1, 86), Student(2, 60), Student(3, 72), Student(4, 95), Student(5, 66) }; int maxGradeStNum = maxGradeIndex(a); cout << "成績(jī)最好學(xué)生的學(xué)號(hào)是:" << a[maxGradeStNum].num << endl; cout << "成績(jī)最好學(xué)生的成績(jī)是:" << a[maxGradeStNum].grade << endl; getchar(); return 0; }
上傳時(shí)間: 2016-04-23
上傳用戶:burt1025
#include <iostream.h> #include <string.h> #include <iomanip.h> #include "Stud.h" Stud::Stud(){} char *Stud::getno() //獲取學(xué)號(hào) { return no; } char *Stud::getname() //獲取姓名 { return name; } char *Stud::getsex() //獲取性別 { return sex; } char *Stud::getminzu() //獲取民族 { return minzu; } char *Stud::getaddress() //獲取出生地 { return address; } char *Stud::getbirth() //獲取出生年月 { return birth; } int Stud::gettag() //獲取姓名 { return tag; } void Stud::changeno(char n[]) //設(shè)置學(xué)號(hào) { strcpy(no,n); } void Stud::changename(char na[]) //設(shè)置姓名 { strcpy(name,na); } void Stud::changesex(char s[]) //設(shè)置性別 { strcpy(sex,s); } void Stud::changeminzu(char m[]) //設(shè)置民族 { strcpy(minzu,m); } void Stud::changeaddress(char a[]) //設(shè)置出生地 { strcpy(address,a); } void Stud::changebirth(char b[]) //設(shè)置出生年月 { strcpy(birth,b); } void Stud::addstudent(char *rn,char *rna) //增加學(xué)生 { strcpy(no,rn); strcpy(name,rna); } void Stud::addstudent(char *rn,char *rna,char *rs,char *rm,char *ra,char *rb) //增加學(xué)生 { tag=0; strcpy(no,rn); strcpy(name,rna); strcpy(sex,rs); strcpy(minzu,rm); strcpy(address,ra); strcpy(birth,rb); } void Stud::delstud() //設(shè)置刪除標(biāo)記 { tag=1; } void Stud::disp() //輸出學(xué)生信息 { cout<<setw(15)<<no<<setw(10)<<name<<setw(10)<<sex<<setw(10)<<minzu<<setw(10)<<address<<setw(10)<<birth<<endl; } void Stud::display() //輸出學(xué)生信息 { cout<<setw(15)<<no<<setw(10)<<name; }
標(biāo)簽: 學(xué)生
上傳時(shí)間: 2016-12-29
上傳用戶:767483511
程序顯示: 一年內(nèi)總降雨量、平均每月的降雨量、降雨量最大的月份和最小的月份。 #include<iostream> using namespace std; #include<stdlib.h> int main() .. .. .. cout<<"降雨量最小的月份是:"<<minyue<<"月 "<<"降雨量為:"<<min<<endl; }
標(biāo)簽: float 編寫(xiě) 程序 用戶 數(shù)組 存儲(chǔ) 輸入
上傳時(shí)間: 2018-03-27
上傳用戶:shayusha
#include <iostream> #include <stdio.head> #include <stdlib.head> #include <string.head> #define ElemType int #define max 100 using namespace std; typedef struct node1 { ElemType data; struct node1 *next; }Node1,*LinkList;//鏈棧 typedef struct { ElemType *base; int top; }SqStack;//順序棧 typedef struct node2 { ElemType data; struct node2 *next; }Node2,*LinkQueue; typedef struct node22 { LinkQueue front; LinkQueue rear; }*LinkList;//鏈隊(duì)列 typedef struct { ElemType *base; int front,rear; }SqQueue;//順序隊(duì)列 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 //1.采用鏈?zhǔn)酱鎯?chǔ)實(shí)現(xiàn)棧的初始化、入棧、出棧操作。 LinkList CreateStack()//創(chuàng)建棧 { LinkList top; top=NULL; return top; } bool StackEmpty(LinkList s)//判斷棧是否為空,0代表空 { if(s==NULL) return 0; else return 1; } LinkList Pushead(LinkList s,int x)//入棧 { LinkList q,top=s; q=(LinkList)malloc(sizeof(Node1)); q->data=x; q->next=top; top=q; return top; } LinkList Pop(LinkList s,int &e)//出棧 { if(!StackEmpty(s)) { printf("棧為空。"); } else { e=s->data; LinkList p=s; s=s->next; free(p); } return s; } void DisplayStack(LinkList s)//遍歷輸出棧中元素 { if(!StackEmpty(s)) printf("棧為空。"); else { wheadile(s!=NULL) { cout<<s->data<<" "; s=s->next; } cout<<endl; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 //2.采用順序存儲(chǔ)實(shí)現(xiàn)棧的初始化、入棧、出棧操作。 int StackEmpty(int t)//判斷棧S是否為空 { SqStack.top=t; if (SqStack.top==0) return 0; else return 1; } int InitStack() { SqStack.top=0; return SqStack.top; } int pushead(int t,int e) { SqStack.top=t; SqStack.base[++SqStack.top]=e; return SqStack.top; } int pop(int t,int *e)//出棧 { SqStack.top=t; if(!StackEmpty(SqStack.top)) { printf("棧為空."); return SqStack.top; } *e=SqStack.base[s.top]; SqStack.top--; return SqStack.top; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 //3.采用鏈?zhǔn)酱鎯?chǔ)實(shí)現(xiàn)隊(duì)列的初始化、入隊(duì)、出隊(duì)操作。 LinkList InitQueue()//創(chuàng)建 { LinkList head; head->rear=(LinkQueue)malloc(sizeof(Node)); head->front=head->rear; head->front->next=NULL; return head; } void deleteEle(LinkList head,int &e)//出隊(duì) { LinkQueue p; p=head->front->next; e=p->data; head->front->next=p->next; if(head->rear==p) head->rear=head->front; free(p); } void EnQueue(LinkList head,int e)//入隊(duì) { LinkQueue p=(LinkQueue)malloc(sizeof(Node)); p->data=e; p->next=NULL; head->rear->next=p; head->rear=p; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //4.采用順序存儲(chǔ)實(shí)現(xiàn)循環(huán)隊(duì)列的初始化、入隊(duì)、出隊(duì)操作。 bool InitQueue(SqQueue &head)//創(chuàng)建隊(duì)列 { head.data=(int *)malloc(sizeof(int)); head.front=head.rear=0; return 1; } bool EnQueue(SqQueue &head,int e)//入隊(duì) { if((head.rear+1)%MAXQSIZE==head.front) { printf("隊(duì)列已滿\n"); return 0; } head.data[head.rear]=e; head.rear=(head.rear+1)%MAXQSIZE; return 1; } int QueueLengthead(SqQueue &head)//返回隊(duì)列長(zhǎng)度 { return (head.rear-head.front+MAXQSIZE)%MAXQSIZE; } bool deleteEle(SqQueue &head,int &e)//出隊(duì) { if(head.front==head.rear) { cout<<"隊(duì)列為空!"<<endl; return 0; } e=head.data[head.front]; head.front=(head.front+1)%MAXQSIZE; return 1; } int gethead(SqQueue head)//得到隊(duì)列頭元素 { return head.data[head.front]; } int QueueEmpty(SqQueue head)//判斷隊(duì)列是否為空 { if (head.front==head.rear) return 1; else return 0; } void travelQueue(SqQueue head)//遍歷輸出 { wheadile(head.front!=head.rear) { printf("%d ",head.data[head.front]); head.front=(head.front+1)%MAXQSIZE; } cout<<endl; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 //5.在主函數(shù)中設(shè)計(jì)一個(gè)簡(jiǎn)單的菜單,分別測(cè)試上述算法。 int main() { LinkList top=CreateStack(); int x; wheadile(scanf("%d",&x)!=-1) { top=Pushead(top,x); } int e; wheadile(StackEmpty(top)) { top=Pop(top,e); printf("%d ",e); }//以上是鏈棧的測(cè)試 int top=InitStack(); int x; wheadile(cin>>x) top=pushead(top,x); int e; wheadile(StackEmpty(top)) { top=pop(top,&e); printf("%d ",e); }//以上是順序棧的測(cè)試 LinkList Q; Q=InitQueue(); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q,x); } int e; wheadile(Q) { deleteEle(Q,e); printf("%d ",e); }//以上是鏈隊(duì)列的測(cè)試 SqQueue Q1; InitQueue(Q1); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q1,x); } int e; wheadile(QueueEmpty(Q1)) { deleteEle(Q1,e); printf("%d ",e); } return 0; }
標(biāo)簽: 數(shù)據(jù)結(jié)構(gòu) 實(shí)驗(yàn)
上傳時(shí)間: 2018-05-09
上傳用戶:123456..
蟲(chóng)蟲(chóng)下載站版權(quán)所有 京ICP備2021023401號(hào)-1