
设计模式与算法
文章平均质量分 67
梁山话事人
这个作者很懒,什么都没留下…
展开
-
fork()浅学习
fork()浅学习 1.进程的创建 fork #include<stdio.h> #include<stdlib.h> #include<unistd.h> int main(int argc,char *argv[]) { int x=42; int rc= fork(); if(rc<0) fprintf(stderr,"failed"); else if(rc==0) printf("Child process:rc: %d,v原创 2021-09-07 10:39:59 · 128 阅读 · 0 评论 -
设计模式中的几个原则
1.单一职责模式 单一职责模式-每个类实现一个指责 package com.principle.singleresponsibiliity; public class SingleResponsibility1 { public static void main(String[] args) { Teacher tt=new Teacher(); tt.eat("王老师"); Student ss=new Student();原创 2021-01-04 20:43:28 · 100 阅读 · 1 评论 -
二叉树,栈存储及遍历小程序
1.容器 #include<iostream> #include<vector> #include<string> using namespace std; int main() { vector<string>a;//定义一个容器 string tmp;//定义一个字符串 while(cin>>tmp)//将字符串不断放入容器 { a.push_back(tmp); } for(vector<string>::iterato原创 2020-12-07 21:18:50 · 275 阅读 · 0 评论 -
数据结构简单学习笔记
1.栈在括号匹配中的应用: //括号匹配问题 bool bracketCheck(char str[],int length) { SqStack S; InitStack(S for(int i=0;i<length;i++) { if(str[i]='('||str[i]='['||str[i]='{') { Push(S,str[i]); } else{ char topElem; Pop(S,toElem); if(str[i]==')'&a原创 2020-12-07 21:17:20 · 186 阅读 · 0 评论 -
扑克牌
扑克牌 扑克牌实现简单的发牌 需要进一步改进 #include<stdio.h> #include<stdlib.h> #include<time.h> // #define NDEALS 3000 #define NPLAYERS 6 typedef enum{clubs,diamonds,hearts,spades} cdhs; //四种牌:枚举类型 struct card { int pips; cdhs suit; }; card assign_values原创 2020-12-07 21:10:42 · 146 阅读 · 0 评论 -
设计模式之简单工厂模式
设计模式 1.简单工厂模式 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-DbUh6oCi-1607346266743)(C:\Users\123\AppData\Roaming\Typora\typora-user-images\1605525525702.png)] 简单工厂模式:父类有两个参数,计算结果参数需要重载。有四个类继承父类 重写了结果的计算方式。工厂类根据传进来的参数进行类的生成。生成的类返回给主函数,这里使用引用方式。用到了父类一定是子类的概念 可以指代原创 2020-12-07 21:05:16 · 102 阅读 · 0 评论