队列表达式求值
摘要:#include <iostream>#include<iomanip>#include <string>#include <sstream>#include<queue>using namespace std;bool fun(char a){ if(a=='*'||a=='/') return true; return false;}double fun1(double i,double j,char a){ if(a=='*') return i*j; else if(a==
阅读全文
posted @
2013-02-25 19:47
叶城宇
阅读(408)
推荐(0)
哈夫曼树
摘要:#include "stdafx.h"#include<iostream>using namespace std;#include<fstream>#include<string>typedef struct {char date; int weight; int parent,lchild,rchild;}Htnode,*huffmanTree;typedef char* * huffmancode;void fun(Htnode *p,char a,int b){ p->date=a; p->weight=b; p->
阅读全文
posted @
2013-02-25 19:44
叶城宇
阅读(402)
推荐(0)
二叉树的遍历
摘要://二叉树的基本操作#include<iostream>using namespace std;typedef char Telemtype;typedef struct bitnode { Telemtype date; int mark; bitnode *lchild,*rchild;}*bitree;int initbitree(bitree &T){ T=NULL; return 1; } int createbitree (bitree &T){ //按先序次序输入二叉树中节点的值(一个字符),空格字符表示空树; //构造二叉树表表示的二叉树T. cha
阅读全文
posted @
2013-02-25 19:39
叶城宇
阅读(183)
推荐(0)
迷宫问题
摘要://链表栈#include "stdafx.h"#include<iostream>using namespace std;typedef struct{ int line; int count; int dir;}Elemtype;typedef struct s{ Elemtype elem ; s* next; }s;//链表栈的结点类型为结构体;void initstack(s*&base){ base=(s*) malloc (sizeof(s)); base->next=NULL;}void push(s*&base ,Elem
阅读全文
posted @
2013-02-25 19:37
叶城宇
阅读(257)
推荐(0)
约瑟夫环
摘要://循环链表.h#include "stdafx.h"#include<iostream>using namespace std;typedef int Elemtype[2] ;typedef struct l { Elemtype elem; struct l* next;}l;//链表的结点类型为结构体;l* r,*f;bool initlist(l*&a){ a=(l*)malloc(sizeof(l)); if(!a)return false; (*a).next=a;r=a;f=a; return true;}//键头结点;void link
阅读全文
posted @
2013-02-25 19:34
叶城宇
阅读(181)
推荐(0)
字符串倒置
摘要:include irvine32.inc.dataa byte "abhgfu s women"b byte sizeof a dup(0).codemain proc;打印出字符串;mov edx,offset acall writestringcall crlfmov esi,offset amov edi,offset bmov ecx,(sizeof a)add esi,(sizeof a)-1mov eax,0L1: mov al, byte ptr [esi] mov [edi], eax inc edi dec esi LOOP L1mov edx ,offs
阅读全文
posted @
2013-02-25 19:18
叶城宇
阅读(174)
推荐(0)
数组求和
摘要:include irvine32.inc.dataarray dword 10000h,20000h,30000h,20000h,10000hthesum dword ?.codearraysum proc push esipush ecxmov eax,0L1: add eax,[esi] add esi,type dword LOOP L1 pop ecx pop esi retarraysum endp main proc mov esi,offset array mov ecx,lengthof array call arraysum mov thesum,eax call wri..
阅读全文
posted @
2013-02-25 19:17
叶城宇
阅读(136)
推荐(0)
数组的输出
摘要:include irvine32.inc.datai dword 1,2,34,5,6,7,8,9,0,11.codemain procmov ecx,0;mov esi,offset imov ecx,lengthof i;;mov eax,ecx;;call writeint;call crlfmov ebx,dword;call dumpmem;exitmain endpend main
阅读全文
posted @
2013-02-25 19:16
叶城宇
阅读(169)
推荐(0)
日期
摘要:include irvine32.incstandard=2000;.dataday word 15;month word 5;year word 2012;ymd word ?.codemain procmov eax,0;mov ebx,0;mov ax,year;sub ax,standard;shl ax,9;mov bx,month;shl bx,5;add ax ,bx;add ax,day;mov ymd,ax;call writebin;exitmain endpend main
阅读全文
posted @
2013-02-25 19:15
叶城宇
阅读(113)
推荐(0)
时间
摘要:include irvine32.inc.datatime word 0101011000111001bhh word ?mmm word ?sss word ?.codemain procmov eax,0;mov ax,time;shr ax,11;mov hh,ax;call writedec;mov al,':'call writechar;mov ax,time;shr ax,5;and ax,111111b;mov mmm,ax;call writedec;mov al,':'call writechar;mov ax,time;and ax,111
阅读全文
posted @
2013-02-25 19:14
叶城宇
阅读(103)
推荐(0)
临时变量
摘要:include irvine32.inc.datastr1 byte "赋值后的结果:",0;.codemain proccall swap;;mov ebx,offset str1;;call writestring;exitmain endpswap procpush ebp;mov ebp,esp;sub esp,32;mov ecx,29;mov eax,ebp;L1: mov byte ptr [eax-32],'@'; inc eax; loop L1; mov byte ptr[eax-32],0 mov edx,offset str1; ca
阅读全文
posted @
2013-02-25 19:13
叶城宇
阅读(206)
推荐(0)
两个数交换
摘要:include irvine32.incchang proto ,v1:ptr dword,v2: ptr dword.datai dword ?j dword ?str1 byte "交换前的是:",0;str2 byte "交换后的结果:",0;.codemain proccall readintmov i,eax;call readintmov j,eax;mov edx,offset str1call writestring;mov eax,i;call writeint;mov al,','call writecharmov e
阅读全文
posted @
2013-02-25 19:12
叶城宇
阅读(132)
推荐(0)
参数传值(数组赋值)
摘要:include irvine32.incsub2 proto a:ptr dword,l1:dword.datai dword 10 dup(?);str1 byte "开始初始化的值:",0;.codemain procmov edx,offset str1;call writestringinvoke sub2 ,offset i,lengthof i;call crlf;mov esi,offset i;mov ecx,lengthof i;mov ebx,dword;call dumpmem;exitmain endpsub2 proc, a:PTR dword,
阅读全文
posted @
2013-02-25 19:11
叶城宇
阅读(259)
推荐(0)
while循环
摘要:include irvine32.inc.datai dword 8j dword 29x dword 0.codemain proc mov eax,0L: cmp i,10 jl L1 cmp j,15 jng next ;call writeint ;call crlfL1: inc i dec j inc x LOOP Lnext:mov eax,xcall writeintexitmain endpend main
阅读全文
posted @
2013-02-25 19:09
叶城宇
阅读(154)
推荐(0)
简单语法
摘要:;功能:查找32位之间的赋值语句是否有语法错误,如果没有就输出,如果有就输出错误;;为了减少情况判断;特意规定mov后面的第一个参数必须为寄存器。;赋值语句中32位赋值和16位、8位等情况的赋值语法完全相同,;所以这里只判断32位赋值的情况,并且假设这里的内存操作数一定是写对的;用str1来存储要判断的语句,用str2来存储内存操作数的类型。include irvine32.inc.datai dword 1;c1 byte "改语法不正确:",0;c2 byte "相等",0;c3 byte "该语法正确",0;c4 byte &q
阅读全文
posted @
2013-02-25 19:08
叶城宇
阅读(164)
推荐(0)
移位指令实现乘法
摘要:include irvine32.inc;.datai dword 0;sum qword 0;str1 byte "请输入16进制的(32位整数)乘数和被乘数",0str2 byte "乘积为:",0;j dword 0;.codemain procL1: mov edx,offset str1; call writestring; mov j,0; mov eax,0;eax为(低32位)乘积值; mov ebx,0;edx为(低32位)乘积值的中间值 mov edx,0; mov esi,0;dsi为(高32位)乘积值的中间值 mov edi,0;
阅读全文
posted @
2013-02-25 19:07
叶城宇
阅读(534)
推荐(0)
斐波那序列求值
摘要:include irvine32.inc.datastr1 byte "请输入所要的斐波那序列的位置:",0;str2 byte "斐波那序列的结果为:",0;str3 byte "斐波那序列的最大值为N=",0;i dword 2;var1 dword 3 dup(1,0,0);var2 dword 3 dup(1,0,0);.codemain proc mov ecx,0; mov eax,0;L1: mov var1,1; mov dword ptr var1+4,0; mov dword ptr var1+8,0; mov v
阅读全文
posted @
2013-02-25 19:06
叶城宇
阅读(225)
推荐(0)
大整数与2的N次方相乘
摘要:include irvine32.inc.datavar1 dword 4 dup(0,0,0,0);str1 byte "请用16进制输入一个大整数(最高位为96位)",0;str2 byte "结果为:",0;str3 byte "请输入2的次方数(十进制--不能超过31):",0;i dword 0;j dword 0;str4 byte "输入的绝对值为:",0.codemain procL4: mov dword ptr var1+12,0; mov j,0;正负数的标志;0为正数,1为负数; mov e
阅读全文
posted @
2013-02-25 19:03
叶城宇
阅读(294)
推荐(0)
合数转换为两个素数之和
摘要://输入一个大于6的偶数,这个数一定能写成两个素数的和,比如8=3+5;#include<iostream>using namespace std; int prime(int x);void gotbaha(int x);void main(){ int a; cin>>a; if((a<6)||(a%2==1)) cout<<"the wrong number"<<endl; else gotbaha(a); }int prime(int x){ int i;for(i=2;i<x;i++) if(x%i==0
阅读全文
posted @
2013-02-23 16:02
叶城宇
阅读(208)
推荐(0)
构造和析构函数
摘要:#include<iostream>using namespace std;class School{private: char*sname; int snumber,score;public: void show( ) {cout<<"sname is:"<< sname<<endl; cout<<"snumber is:"<< snumber<<endl; cout<<"score is:"<< score<<e
阅读全文
posted @
2013-02-23 16:01
叶城宇
阅读(147)
推荐(0)
构造函数化简分数
摘要:#include <iostream>using namespace std;#include<cmath>class number {private :int son,mother;public: number (int son2,int mother2) { int a,b,k,i=0; if(son2>mother2) { a=son2;b=mother2;} else {a=mother2;b=son2;} for( ; ;i++) {if(a%b==0) break; else { k=a;a=b;b=k%b;} } son=s...
阅读全文
posted @
2013-02-23 16:00
叶城宇
阅读(210)
推荐(0)
函数引用的简单应用
摘要://应用调用函数的引用,将一维数组的最大值换成自己输入的一个X的数,再将数组输出;# include <iostream>using namespace std;int &fun(int a[],int b);int* max;void main (void){ int a[]={5,9,8,7,12,33,66,88,7},n,x; cout<<"please enter x"<<endl; cin>>x; n=sizeof(a)/sizeof(int); fun(a,n)=x; for(int i=0;i<n
阅读全文
posted @
2013-02-23 15:59
叶城宇
阅读(159)
推荐(0)
汉诺塔问题1
摘要:# include <iostream>using namespace std;void move (int n,char a,char b){ cout<<n<<"盘"<<a<<" to "<<b<<endl;}void h1(int n,char x,char y,char z){ if(n==1) move(n,x,z); else { h1(n-1,x,y,z); move (n,x,z); h1(n-1,y,x,z); }}void main (){ int n
阅读全文
posted @
2013-02-23 15:56
叶城宇
阅读(138)
推荐(0)
字符数组拷贝2
摘要:#include<iostream>using namespace std;char dest[10] ;char* copystr(char source[], int m ,int x) { int i,j=0; for(i=m-1;i<x;i++) { dest[j]=source[i]; j++;} char *p=dest; return p; }void main(){ int i,m,x; char source[10] ; for(i=0;i< 10;i++) cin>>source[i]; cout<<"请输入0-10
阅读全文
posted @
2013-02-23 15:55
叶城宇
阅读(187)
推荐(0)
字符数组拷贝1
摘要:#include<iostream>using namespace std;void copystr(char source[],char dest[],int m ,int x) { int i,j=0 ; for(i=m-1;i<x;i++) { dest[j]=source[i]; j++;} }void main(){ int i,m,x; char source[10],dest[10]; for(i=0;i< 10;i++) cin>>source[i]; cout<<"请输入0-10之间的数"<<en
阅读全文
posted @
2013-02-23 15:54
叶城宇
阅读(165)
推荐(0)
位操作2
摘要://某任务需要在A、B、C、D、E着5人中物色人员去完成,但派人受限于下列条件://(1)若A去,则B跟去(2)D、E两人中必有人去(3)B,C两人中必有人去,但只去一人//(4)C,D两人要么都去,要么都不去(5)若E去,则A,B都去#include<iostream>using namespace std;void print(int n);void main(){ for(int i=0;i<32;i++){ if(i>>4 && !((i & 8) ))continue; if(!((i&2) ) &&!(i
阅读全文
posted @
2013-02-23 15:45
叶城宇
阅读(153)
推荐(0)
位操作1
摘要://某任务需要在A、B、C、D、E着5人中物色人员去完成,但派人受限于下列条件://(1)若A去,则B跟去(2)D、E两人中必有人去(3)B,C两人中必有人去,但只去一人//(4)C,D两人要么都去,要么都不去(5)若E去,则A,B都去#include<iostream>using namespace std;void print(int n);void main(){ for(int i=0;i<32;i++){ bool A=i&16,B=i&8,C=i&4,D=i&2,E=i&1; if(A && !B) cont
阅读全文
posted @
2013-02-23 15:44
叶城宇
阅读(277)
推荐(0)
write
摘要:#include<iostream>#include<cstring>using namespace std;void main(){const char*state1="florida";const char*state2="kansas";const char*state3="euphoria";int len=strlen(state2);cout<<"increasing loop index;\n";int i;for(i=1;i<=len;i++){ cout.
阅读全文
posted @
2013-02-23 15:40
叶城宇
阅读(369)
推荐(0)
string流
摘要:#include<iostream>#include<sstream>using namespace std;void main(){freopen("testdata.txt","rt",stdin);for(string s;getline(cin,s); ){ int a,sum=0; for(istringstream a1(s);a1>>a;sum+=a); cout<<sum<<endl;}}
阅读全文
posted @
2013-02-23 15:12
叶城宇
阅读(135)
推荐(0)
STL_vector2
摘要:#include<iostream>#include<vector>#include<algorithm>#include<string>using namespace std;struct R{ string title; int rating;};bool operator<(const R&r1,const R&r2);bool worsethan(const R&r1,const R&r2);bool fillR(R& rr);void showR(const R& rr);void
阅读全文
posted @
2013-02-23 15:10
叶城宇
阅读(168)
推荐(0)
STL_vector1
摘要:#include<iostream>#include<vector>#include<string>using namespace std;struct R{ string title; int rating;};bool fillr(R & rr);void showr(const R & rr);void main(){vector<R>books;R temp;while(fillr(temp)) books.push_back(temp);int num=books.size();cout<<"siz
阅读全文
posted @
2013-02-23 15:09
叶城宇
阅读(186)
推荐(0)
STL_set
摘要:#include<iostream>#include<algorithm>#include<iterator>#include<set>#include<string>using namespace std;void main(){ const int N=6; string s1[N]={"buffoon","thinkers","for","heavy","can","for"}; string s2[N]={&
阅读全文
posted @
2013-02-23 15:08
叶城宇
阅读(161)
推荐(0)
STL_queue
摘要:#include<iostream>#include<algorithm>#include<queue>using namespace std;void main(){ queue<int>s; s.push(1); s.push(2); s.push(3); cout<<"size::"<<s.size()<<endl; cout<<"front::"<<s.front()<<endl; cout<<"back:
阅读全文
posted @
2013-02-23 15:06
叶城宇
阅读(122)
推荐(0)
STL_multimap
摘要:#include<iostream>#include<string>#include<map>#include<algorithm>using namespace std;typedef int keytype;typedef pair<const keytype,string> pair1;typedef multimap<keytype,string> mapcode;void main(){ mapcode codes;codes.insert(pair1(415,"san francisco")
阅读全文
posted @
2013-02-23 15:05
叶城宇
阅读(173)
推荐(0)
STL_maps
摘要:#include<iostream>#include<algorithm>#include<string>#include<map>using namespace std;/*struct T1{ int v; bool ope1(const T1&a){ return(v<a.v); }};struct T2{ int v;};struct cmp{ const bool op(const T2 &a,const T2 &b ) { return (a.v<b.v);}};*/void mian(){ //m
阅读全文
posted @
2013-02-23 15:04
叶城宇
阅读(148)
推荐(0)
STL_list2
摘要:#include<iostream>#include<list>#include<iterator>using namespace std;void main(){list<int>one(5,2);int stuff[5]={1,2,4,8,6};list<int>two;two.insert(two.begin(),stuff,stuff+5);int more[6]={6,4,2,4,6,5};list<int>three(two);three.insert(three.end(),more,more+6);cout
阅读全文
posted @
2013-02-23 15:03
叶城宇
阅读(128)
推荐(0)
STL_list1
摘要:#include<iostream>#include<list>#include<string>using namespace std;void main(){ list<int>lis; list<int>::iterator li; for(int i=0;i<3;i++) { lis.push_front(i), lis.push_back(i); } lis.sort(); cout<<"size::"<<lis.size()<<endl; for(li=lis.b
阅读全文
posted @
2013-02-23 15:02
叶城宇
阅读(132)
推荐(0)
STL_inserts
摘要:#include<iostream>//#include<list.h>#include<iterator>#include<vector>#include<string>using namespace std;void main(){ string s1[4]={"fine","fish","fashion","fate"}; string s2[2]={"busy","bate"}; string s3[3]={
阅读全文
posted @
2013-02-23 15:01
叶城宇
阅读(104)
推荐(0)
STL_deque
摘要:#include<iostream>#include<algorithm>#include<deque>#include<string>//#include <vector>#include <map>//#include <set>using namespace std;void main(){ deque<char>a; for(int i=0;i<5;a.push_back('5'-i++)); cout<<"size::"<<
阅读全文
posted @
2013-02-23 15:00
叶城宇
阅读(139)
推荐(0)
STL_copyit
摘要:#include<iostream>#include<iterator>#include<vector>using namespace std;void main(){ int a[10]={6,7,2,9,4,11,8,7,10,5}; vector<int>b(10); copy(a,a+10,b.begin()); cout<<"let the b be a!\n"; ostream_iterator<int,char>out(cout," "); copy(b.begin()
阅读全文
posted @
2013-02-23 14:59
叶城宇
阅读(133)
推荐(0)
getline
摘要:#include<iostream>#include<string>using namespace std;void main(){ string s1,s2="6";int s3;cin>>s1;cout<<"s1::"<<s1<<endl;getline(cin,s2,'x');cout<<"s2::"<<s2<<"%%%"<<endl;//getline(cin,s3);}
阅读全文
posted @
2013-02-23 14:58
叶城宇
阅读(166)
推荐(0)
队列的基本操作
摘要://队列的链式存储结构(还没写遍历)==============#include<iostream>using namespace std;typedef struct qnode{ int data; struct qnode *next ;}qnode,*queueptr;typedef struct{ queueptr front; queueptr rear;}linkqueue;///////////////////int initqueue(linkqueue &q){ q.front=q.rear=(queueptr)malloc (sizeof(qnode)
阅读全文
posted @
2013-02-23 14:55
叶城宇
阅读(201)
推荐(0)
动态开辟二维数组
摘要:#include<iostream>using namespace std;void main(){ int a=5,b=6;int i,j;int **c = new int*[b]; for( i=0;i<b;i++) c[i] = new int[a]; //使用时用 arData[i][j]格式 0 <=i <nHeight, 0 <=j <nWidth //结束时清除 cout<<c<<endl;for(i=0;i<b;i++) for(j=0;j<a;j++) c[i][j]=i+j;for(i=0;i&
阅读全文
posted @
2013-02-23 14:54
叶城宇
阅读(132)
推荐(0)
图的遍历
摘要:#include<iostream>using namespace std;typedef struct qnode{ int data; struct qnode *next ;}qnode,*queueptr;typedef struct{ queueptr front; queueptr rear;}linkqueue;///////////////////int initqueue(linkqueue &q){ q.front=q.rear=(queueptr)malloc (sizeof(qnode)); if(!q.front) return 0; q.fron
阅读全文
posted @
2013-02-23 14:52
叶城宇
阅读(183)
推荐(0)