当前位置: 首页 > news >正文

企业网站怎么做的好看h5网站快速搭建

企业网站怎么做的好看,h5网站快速搭建,网站模板 家,简述网络营销的推广方法首先学习队列#xff0c;队列有先进先出的特性。广度优先遍历需要基于队列实现#xff0c;C中的stl引入了队列的实现方式。队列支持push()#xff0c;进入队尾#xff0c;pop()出队#xff0c;队头出队#xff0c;front()获取队首元素#xff0c;back()获取队尾元素队列有先进先出的特性。广度优先遍历需要基于队列实现C中的stl引入了队列的实现方式。队列支持push()进入队尾pop()出队队头出队front()获取队首元素back()获取队尾元素empty()判断队列是否为空。 第一题是约瑟夫环问题。 #include stdio.h #include queue using namespace std; int main() {queueint myqueue;int n,p,m;while(scanf(%d%d%d, n,p,m)!EOF){if(n 0p0m0) break;//生成第一轮报数的队列//p, p1,p2,...,n,1,2,....int no p;//孩子编号for(int i 0; i n;i){myqueue.push(no);no;if(non) no1;}//开始报数int say 1;while(1){int cur myqueue.front();myqueue.pop();if(say m){say 1;if(myqueue.empty()){printf(%d\n, cur);break;}else{printf(%d,, cur);}}else {say;myqueue.push(cur);}}}return 0; } 第二题是排队打饭分情况讨论即可主要注意time是long long类型使用int这题过不了。 #include stdio.h #include queue using namespace std; struct Student{int a;//到达时刻int t;//打饭耗时int b;//最大等待时间 }; int main(){queueStudent que;int n;scanf(%d, n);for(int i 0; in;i){int ai,ti,bi;scanf(%d%d%d, ai, ti,bi);Student s1;s1.a ai;s1.b bi;s1.t ti;que.push(s1);//读入学生序列}long long time 1;//记录当前时刻while(!que.empty()){Student stu que.front();if(time(stu.astu.b)){printf(-1 );que.pop();}else if(timestu.atime(stu.astu.b)){printf(%d , time);time stu.t;que.pop();}else if(timestu.a){time stu.a;printf(%lld , time);time stu.t;que.pop();}} } 下面学习栈后进先出。深度优先遍历、表达式解析、递归会使用栈。stack支持push()入站pop()出栈top()获取栈顶元素栈只支持获取栈顶元素empty()获取栈是否为空。 第三题是编排字符串。栈的简单应用。 #include stdio.h #include stack #include string using namespace std; int main(){int n;scanf(%d, n);stack string st1;for(int i 0; in;i){char mid[20];scanf(%s, mid);string str mid;st1.push(str);stackstring mystack;mystack st1;int num 1;while(!mystack.empty()){if(num4) break;string str1 mystack.top();printf(%d%s , num, str1.c_str());num;mystack.pop();}printf(\n);}} 第四题是括号匹配经典题目。 #include stdio.h #include stack #include string using namespace std; int main() {char arr[20000];scanf(%s, arr);string str arr;stackchar mystack;mystack.push(str[0]);for(int i 1;i str.size();i){if(str[i] ||str[i] (||str[i] {||str[i] [){mystack.push(str[i]);}else if(str[i]){if(mystack.empty()) {printf(no);return 0;}char res mystack.top();if(res ) mystack.pop();else {printf(no);return 0;}}else if(str[i])){if(mystack.empty()) {printf(no);return 0;}char res mystack.top();if(res () mystack.pop();else {printf(no);return 0;}}else if(str[i]}){if(mystack.empty()) {printf(no);return 0;}char res mystack.top();if(res {) mystack.pop();else {printf(no);return 0;}}else if(str[i]]){if(mystack.empty()) {printf(no);return 0;}char res mystack.top();if(res [) mystack.pop();else {printf(no);return 0;}}}if(mystack.empty()true) printf(yes);else printf(no);return 0; } 第五题是堆栈的使用​​​​​​​简单模拟。 #include stdio.h #include string #include stack using namespace std; int main() {int n;while (scanf(%d, n) ! EOF) {stack int mystack;for (int i 0; i n; i) {char op[2];scanf(%s, op);string op2op;if (op2 A) {if (mystack.empty()) printf(E\n);else printf(%d\n, mystack.top());} else if (op2 O) {if (!mystack.empty()) mystack.pop();} else if (op2 P) {int num;scanf(%d, num);mystack.push(num);}}}return 0; } 第六题是计算表达式写了半天代码逻辑不对气完了。建立运算符栈与运算数栈。从左向右扫描表达式遇到操作数就加入操作数栈扫描到运算符若运算符栈为空则直接压入运算符栈若运算符栈不为空但当前运算符优先级大于栈顶运算符也执行压栈操作。若运算符栈不为空但当前运算符优先级低于栈顶运算符则弹出栈内的运算符同时弹出操作数直到当前运算符优先级再次大于栈顶运算符压入栈中。 #include stdio.h #include string #include stack #include map using namespace std; int main() {char str[1000] {0};mapchar, int prio {{\0, 0}, {, 1}, {-, 1}, {*, 2}, {/, 2}};while (scanf(%s, str) ! EOF) {string numstr ;stack char opstack;stack double numstack;for (int i 0;; i) {if (str[i] 0 str[i] 9) {numstr.push_back(str[i]);} else {double num stod(numstr);numstr ;//数值提取numstack.push(num);//什么时候弹栈栈非空新的op的优先级不高于栈顶的优先级//循环弹栈和计算while (!opstack.empty() prio[str[i]] prio[opstack.top()]) {double right numstack.top();numstack.pop();double left numstack.top();numstack.pop();char curop opstack.top();opstack.pop();if (curop ) numstack.push(left right);else if (curop -) numstack.push(left - right);else if (curop *) numstack.push(left * right);else if (curop /) numstack.push(left / right);}//栈为空或者新运算符的优先级大于栈顶运算符if (str[i] \0) {printf(%d\n, (int)numstack.top());break;} else opstack.push(str[i]);}}}return 0; } 第七题是模拟出入栈​​​​​​​。 #include bits/stdc.h using namespace std;int main() {string s;while (cin s) {stackchar stk;int j 0; //j用来扫描出栈序列s的for (char i a; i z; i) {stk.push(i); //每次按顺序入栈一个while (stk.size() stk.top() s[j]) {j; //出栈序列向后走匹配下一个stk.pop(); //出栈}}if (stk.empty()) cout yes\n; //栈空了就是匹配的else cout no\n;}return 0; }
http://www.dnsts.com.cn/news/264450.html

相关文章:

  • 顺企网哈尔滨网站建设it外包服务网
  • 网站建设有利点北京注册公司地址费用
  • 网站模板设计工具免费全自动推广平台
  • 全国分类信息网站网站建设与管理小论文
  • 宏润建设集团有限公司网站手机app制作开发
  • 十大下载网站免费安装网站公司排行榜前十名
  • 舒兰网站建设重庆建造师管理系统查询系统
  • 怎么补网站漏洞问答系统网站模板
  • 营销型网站建设计划书网站论坛建设方案
  • 花都低价网站建设wordpress下载美化
  • 做微博分析的网站电商平台app大全
  • 卖东西的网站模板免费下载软件工程师中级证书
  • 上海网站建设推广江北网站建设的技术
  • 吉林省建设厅网站杨学武长春网站建设联系吉网传媒优
  • 应聘网站建设工程师seo和sem是什么
  • 社区网站建设资金申请海曙网站制作
  • 广东省住建厅官方网站怎么样做免费的百度seo
  • 宁波公司网站制作做微信公众号海报的网站
  • 灰系网站个人网站开发技术
  • 小程序商店怎么注销建站优化系统
  • wordpress网站转移安徽省建设工程网站
  • 成都美誉网站设计网站建设 6万
  • 宁波建网站可按需定制贵州毕节建设局网站官网
  • 济南网站制作案例linux wordpress 伪静态
  • 常德网站网站建设网站开发背景和意义
  • 襄阳做网站排行榜wordpress怎么建app
  • 在那个网站做ppt可以赚钱长尾关键词爱站
  • 深圳卓富通做网站深圳创业补贴政策2024最新
  • app网站建设手机APP软件开发杭州小蜜蜂网站建设
  • 做网站要素网站建设丶金手指下拉13