1.称水果。

#include<iostream>
using namespace std;double capital=0.0;
double cal(int num,double quantity)
{switch(num){case 0:return quantity*1.50;case 1:return quantity*1.70;case 2:return quantity*4.60;case 3:return quantity*0.90;case 4:return quantity*2.50;case 5:return quantity*3.70;case 6:return quantity*7.60;case 7:return quantity*3.90;}} int main()
{cout<<"Reminder:This shop provides eight kinds of fruits,as follows (the number and name of the fruit are on the left,and the unit price is on the right)."<<endl;cout<<"0 Watermelon 1.50 \t 1 Papaya 1.70  \t 2 Cantaloupe 4.60 \t 3 Apple 0.9  \t 4 Pear 2.50 \t 5 Grapefruit 3.70 \t 6 Kiwi 7.60 \t 7 Hawthorn 3.9 "<<endl;int num_choice=0;while(1){int Y_N;cout<<"Please enter the quantity of the type you want to buy:";cin>>num_choice;if(num_choice==0){cout<<"Are you sure you just have a look?Would you want to buy some?Please press 1 to continue,otherwise press 0 to exit directly."<<endl;cin>>Y_N;if(Y_N==0){cout<<"Exit successfully. "<<endl;break;}else if(Y_N==1){}elsecout<<"Don't make trouble,lose according to the regulations,dear."<<endl;}else{cout<<"The category numbers are:";int *choice=new int[num_choice];double *quantity_choice=new double[num_choice];for(int i=0;i<num_choice;i++)cin>>choice[i];cout<<"Please enter the quantity corresponding to the purchase type:";for(int i=0;i<num_choice;i++)cin>>quantity_choice[i];for(int j=0;j<num_choice;j++){capital+=cal(choice[j],quantity_choice[j]);}cout<<"Continue shopping?Please press 1 to continue,otherwise press 0,start settlement."<<endl;cin>>Y_N;if(Y_N==0){cout<<"Start settlement,please pay "<<capital<<" yuan.";break;}else if(Y_N==1){}elsecout<<"Don't make trouble,lose according to the regulations,dear."<<endl;delete[] choice;choice=NULL;delete[] quantity_choice;quantity_choice=NULL;}}return 0;
}

2.Huffman编码

#include<iostream>
#include<cstring>
using namespace std;struct huffTree
{int parent;int lchild;int rchild;int weight;string flag;
};struct Lowest_Node
{char ch;int ch_num;
};void coding(int length,huffTree tree[],int n,int &a,int &b)
{int i;int r,s;r=s=length;for(i=0;i<n;i++){if((tree[i].weight<r)&&(tree[i].parent==-1)){r=tree[i].weight;a=i;}}for(i=0;i<n;i++){if((tree[i].weight<s)&&(i!=a)&&(tree[i].parent==-1)){s=tree[i].weight;b=i;}}
}void frequency(string str)
{int length=str.length();Lowest_Node*node=new Lowest_Node[length];int i,j;for(i=0;i<length;i++)node[i].ch_num=0;int char_type_num=0;for(i=0;i<length;i++){for(j=0;j<char_type_num;j++)if(str[i]==node[j].ch||(node[j].ch>='a'&&node[j].ch<='z'&&str[i]+32==node[j].ch))break;if(j<char_type_num)node[j].ch_num++;else{if(str[i]>='A'&&str[i]<='Z')node[j].ch=str[i]+32;elsenode[j].ch=str[i];node[j].ch_num++;char_type_num++;}}for(i=0;i<char_type_num;i++){for(j=i;j<char_type_num;j++){if(node[j].ch_num<node[j+1].ch_num){int temp;char ch_temp;temp=node[j].ch_num;ch_temp=node[j].ch;node[j].ch_num=node[j+1].ch_num;node[j].ch=node[j+1].ch;node[j+1].ch_num=temp;node[j+1].ch=ch_temp;}}} for(i=0;i<char_type_num;i++)cout<<"character"<<node[i].ch<<"apppeared"<<node[i].ch_num<<"times"<<endl;   huffTree *huff=new huffTree[2*char_type_num-1];huffTree temp;string *code=new string[2*char_type_num-1];for(i=0;i<2*char_type_num-1;i++){huff[i].lchild=-1;huff[i].parent=-1;huff[i].rchild=-1;huff[i].flag=-1;}for(j=0;j<char_type_num;j++){huff[j].weight=node[j].ch_num;}int min1,min2;for(int k=char_type_num;k<2*char_type_num-1;k++){coding(length,huff,k,min1,min2);huff[min1].parent=k;huff[min2].parent=k;huff[min1].flag="0";huff[min2].flag="1";huff[k].lchild=min1;huff[k].rchild=min2;huff[k].weight=huff[min1].weight+huff[min2].weight;}for(i=0;i<char_type_num;i++){temp=huff[i];while(1){code[i]=temp.flag+code[i];temp=huff[temp.parent];if(temp.parent==-1)break;}}cout<<"The Huffman encoding of each character of the string is:"<<endl;for(i=0;i<char_type_num;i++)cout<<node[i].ch<<" "<<code[i]<<endl;cout<<"The Huffman encoding of the entire string is:"<<endl;for(i=0;i<length;i++){for(j=0;j<char_type_num;j++){if(str[i]==node[j].ch)cout<<code[j];}} delete[] node;node=NULL;delete[] huff;huff=NULL;delete[] code;code=NULL;
}int main(){int length=0;string str;cout<<"please enter a string:"<<endl;cin>>str;frequency(str);return 0; }

3.图书馆管理系统

#include<iostream>
#include<cstring>
using namespace std;struct book
{char ch_num[3];char ch_name[100];char ch_author[10];char ch_publisher[50];
};int main()
{book Book[100];int number=5;strcpy(Book[0].ch_num,"00");strcpy(Book[0].ch_name,"WeChat,make money by playing like this");strcpy(Book[0].ch_author,"wang_yi");strcpy(Book[0].ch_publisher,"Machinery industry Press");strcpy(Book[1].ch_num,"01");strcpy(Book[1].ch_name,"WeChat Marketing Confidential");strcpy(Book[1].ch_author,"cheng");strcpy(Book[1].ch_publisher,"Machinery industry Press");strcpy(Book[2].ch_num,"02");strcpy(Book[2].ch_name,"C++ Primer");strcpy(Book[2].ch_author,"li_pu");strcpy(Book[2].ch_publisher,"Electronic Industry Press");strcpy(Book[3].ch_num,"03");strcpy(Book[3].ch_name," Crazy Android handouts");strcpy(Book[3].ch_author,"li_gang");strcpy(Book[3].ch_publisher,"Electronic industry Press");strcpy(Book[4].ch_num,"04");strcpy(Book[4].ch_name,"Programing");strcpy(Book[4].ch_author,"tan_hao");strcpy(Book[4].ch_publisher,"Tsinghua University Press");cout<<"______________________________Library management system_______________________________________"<<endl;cout<<"The books in stock now hava numbers 00-04,and the book information has the following contents:"<<endl;cout<<"Book number__________book name_______book author________book publisher"<<endl;int choice;int del_num;int modify_num;int inquiry_num;bool cycle=true;while(cycle){cout<<"Information of "<<number<<" books in current inerntory."<<endl;cout<<"Please select the function you want to operate,please correspond to the function selection button:"<<endl;cout<<"0-exit."<<endl;cout<<"1-add."<<endl;cout<<"2-delete."<<endl;cout<<"3-modify."<<endl;cout<<"4-inquiry."<<endl;cin>>choice;switch(choice){case 0:cout<<"Exit successfully.";cycle=false;break;case 1:cout<<"please follow the above information to enter the information of the new book:"<<endl;number++;cin>>Book[number].ch_num>>Book[number].ch_name>>Book[number].ch_author>>Book[number].ch_publisher;break;case 2:cout<<"Which message to delete";cin>>del_num;number--;if(del_num>number)cout<<"No such information."<<endl;else if(del_num==number){strcpy(Book[del_num].ch_author,"");strcpy(Book[del_num].ch_name,"");strcpy(Book[del_num].ch_publisher,"");strcpy(Book[del_num].ch_num,"");}else{for(int i=del_num;i<number;i++){strcpy(Book[i].ch_author,Book[i+1].ch_author);strcpy(Book[i].ch_name,Book[i+1].ch_name);strcpy(Book[i].ch_publisher,Book[i+1].ch_publisher);strcpy(Book[i].ch_num,Book[i+1].ch_num);}}break;case 3:cout<<"Which message to modify:";cin>>modify_num;if(modify_num>number)cout<<"No such information."<<endl;else{cout<<"Enter the new content in order,if part of it is modified,you can enter the original information as it is."<<endl;cin>>Book[modify_num-1].ch_num>>Book[modify_num-1].ch_name>>Book[modify_num-1].ch_author>>Book[modify_num-1].ch_publisher;}break;case 4:cout<<"Which message to inquiry:";cin>>inquiry_num;cout<<Book[inquiry_num].ch_num<<Book[inquiry_num].ch_name<<Book[inquiry_num].ch_author<<Book[inquiry_num].ch_publisher;break;default:break;}}return 0;
}

4,算数优先级。

#include <iostream>
using namespace std;int level(char ch)
{switch( ch){case '!':return 2;break;case '*':return 3;break;case '/':return 3;break;case '%':return 3;break;case '+':return 4;break;case '-':return 4;break;case '=':return 5;break;default:return -1;break;}
}
int main()
{char symbol[3];int value[3];cout<<"From!、*、/、%、+、-、=choose three of the operators to participate in the operation."<<endl;cin>>symbol[0]>>symbol[1]>>symbol[2];value[0]=level(symbol[0]);value[1]=level(symbol[1]);value[2]=level(symbol[2]);if((value[0]==-1)||(value[1]==-1)||(value[2]==-1))cout<<"Operators that are not entered in the library."<<endl;else{for(int i=0;i<3-1;i++){for(int j=i+1;j<3;j++){if(value[i]>value[j]){char temp;temp=symbol[i];symbol[i]=symbol[j];symbol[j]=temp;}}}cout<<"The order of operations is:"<<endl;for(int k=0;k<3;k++)cout<<symbol[k]<<endl;}return 0;
}

2021-09-07 照书码——_——相关推荐

  1. 2021.09.07 移动端APP开发了解一下

    我是大自然的搬运工. Native App翻页类型总结: 微交互:移动端APP页面跳转方式分析 Web App开发步骤: 一步一步教你如何开发h5页面 H5页面跳转的几种方法: H5打开新窗口与页面跳 ...

  2. 橘子CPS联盟操作手册2021.09

    橘子CPS联盟操作手册2021.09 目录 橘子CPS联盟操作手册2021.09 橘子CPS联盟是干嘛的 橘子CPS基本操作流程 PC端操作 1.注册 2.登陆 3.渠道管理 4.分享网站 5.分享网 ...

  3. 实习日志 (2021.09.13)

    2021.09.13星期一 今天把之前的算法题终于给弄明白了,并能够按照自己的思路去把他给完成,总结这个题目并不是很难,最重要的是要把链表给弄懂,一开始由于我对链表不是很熟悉,导致我在写该题目的时候花 ...

  4. Go 1.18将原生支持fuzz test | Gopher Daily (2021.09.21) ʕ◔ϖ◔ʔ

    每日一谚:Clear is better than clever. Go技术生态 Go 1.18合并了对Fuzz测试原生支持的代码 - https://github.com/golang/go/com ...

  5. 视频教程-2021软考信息系统项目管理师_项目管理(下) 视频培训教程-软考

    2021软考信息系统项目管理师_项目管理(下) 视频培训教程 河北师范大学软件学院优秀讲师,项目经理资质,担任操作系统原理.软件工程.项目管理等课程教学工作.参与十个以上百万级软件项目管理及系统设计工 ...

  6. 视频教程-2021软考信息系统项目管理师_项目管理(上) 视频培训教程-软考

    2021软考信息系统项目管理师_项目管理(上) 视频培训教程 河北师范大学软件学院优秀讲师,项目经理资质,担任操作系统原理.软件工程.项目管理等课程教学工作.参与十个以上百万级软件项目管理及系统设计工 ...

  7. php 评论插件,Typecho评论增强插件:TeComment(2017.09.07更新)

    TeComment(2017.09.07更新) Typecho 评论增强插件,可为Typecho评论增加评论工具栏.实现评论列表异步加载以及Ajax提交评论功能 插件地址:TeComment 1.安装 ...

  8. 面试官系统精讲Java源码及大厂真题 - 07 List 源码会问哪些面试题

    07 List 源码会问哪些面试题 勤学如春起之苗,不见其增,日有所长. --陶潜 引导语 List 作为工作中最常见的集合类型,在面试过程中,也是经常会被问到各种各样的面试题,一般来说,只要你看过源 ...

  9. 2021.09.27 MySQL笔记

    2021.09.27 MySQL笔记 文章目录 2021.09.27 MySQL笔记 一.展示当前存在的所有数据库 二.使用(选中)一个数据库 三.创建一个数据表 四.查询并展示该数据库内的所有数据表 ...

  10. 宝宝起名神器小程序源码_支持多种流量主模式

    2022年马上到了,还不知道怎么给虎宝宝取名字么? 那么这款小程序源码就可以帮到你了,这款小程序支持输入姓氏自动起名. 不满意还可以点击换一换来找到满意的,支持起两个字或者三个字的名字. 另外也给该款 ...

最新文章

  1. C语言实现radon变换
  2. 力扣(LeetCode):字符串转换整数 (atoi)
  3. 近几年前端技术盘点以及 2016 年技术发展方向
  4. ASP.NET MVC3 + Ninject.Mvc3 依赖注入原来可以这么简单
  5. python掷骰子期望_python_掷骰子游戏
  6. 手机qq2008触屏版_[进行中]数码手机周年庆
  7. 小程序左右标签滑块排行榜
  8. 2017-2018-2 20179216 《网络攻防与实践》 SQL注入攻击
  9. 工作155:首页样式调整第二次
  10. 远程桌面连接一个域网的计算机,怎样远程控制局域网的另一台电脑(远程桌面)win10...
  11. AspectJ声明式事务配置
  12. 金融系列5《AUTH过程》
  13. Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
  14. JavaScript成都市地图网页代码
  15. Python requests抓取有道翻译 最新版破解js加密
  16. Mysql之DDL(数据定义语言)
  17. 重磅!融云推出「百幄」政企数智办公平台
  18. php7从入门到入坟,《在对家的坟头做直播》
  19. Python爬取摩拜单车位置信息
  20. 【地图导航】3D地图软件是如何做路径规划的?为什么准确率这么高

热门文章

  1. 当500万只能作为摇号的诚意金来临时,你的想法是什么?
  2. 不仅国产手机被撕下遮羞布,其实苹果和三星也已没了遮羞布
  3. Keep your Eyes on the Lane: Real-time Attention-guided Lane Detection
  4. 太湖之光超级计算机应用最高奖,“神威·太湖之光”两项应用入围“戈登·贝尔”奖...
  5. TCP/IP路由技术第一卷静态路由知识回顾
  6. win10taskkill强行结束进程_win10强制关闭进程快捷键
  7. apk+html启动页,案例——APP启动页
  8. C++循环结构设计——韩信点兵
  9. Python代码画喜羊羊怎么画_Python画图的这几种方法,你学会了吗
  10. Docker启动容器启动并映射端口号时报错:Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already