寒假万恶之源3:抓老鼠啊~亏了还是赚了?

1.代码:

#include<iostream>
using namespace std;
int main()
{
    char a/*操作*/;
    int i/*计数工具*/,b=0/*老鼠会开心几天*/;
    int e/*正常的来*/,f/*老鼠会悲伤几天*/;
    int c=1/*老鼠来不来*/,d=0/*奶酪数目*/,g=0/*老鼠数目*/;
    for (i=1;;i++)
    {
        scanf("%c",&a);   
        if(a=='$')  break;
        if(c==1)
            switch(a)
            {
                case 'X':   {e=1;printf("U");break; }  //什么都不放的情况下,老鼠会正常地来,但是会毫无所获
                case 'T':   {f=2;d++;g++;printf("D");break; }   //放下捕鼠夹,定会耗费一块奶酪,并且会打死一只老鼠,而且鼠群会悲伤两天,两天不会派出老鼠
                case 'C':   {b=2;d++;printf("!");break; }   //只放下奶酪,老鼠会开心2天,并且耗费了一块奶酪,只是人会一无所获
            }
        else printf("-");//同理,以下的判断即为负收益的时候
        if(b>0){b--;c=1;e=0;f==0;}//
        else if(b<=0&&e==1) {c=0;e--;}//
        else if(b<=0&&f>0)  {c=0;f--;}//
        else c=1;
    }
    printf("\n%d",g*10-d*3);
}

2.由于本人自身水平有限,所以本人参照刘凯同学的博客进行改编分析,日后需要提升自己独立思考的能力

3.以下是我的流程图

备注;在此同时,需要考虑负收益的情况,即老鼠悲伤的时候,并不会派出老鼠,此时便出现了亏损情况

 备注;在此同时,需要考虑负收益的情况,即老鼠悲伤的时候,并不会派出老鼠,此时便出现了亏损的情况

4.运行结果正确截图

 

转载于:https://www.cnblogs.com/wonzenkei/p/10365767.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/278343.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在Firefox中结合Wolfram Alpha和Google搜索结果

Do you wish there was a way to combine all that Wolfram Alpha and Google goodness together when you search for something? Now you can with the Wolfram Alpha Google extension for Firefox. 您是否希望有一种方法可以在搜索某些内容时将Wolfram Alpha和Google的所有…

kompozer如何启动_使用KompoZer创建网站

kompozer如何启动Are you looking for a way to easily start creating your own webpages? KompoZer is a nice basic website editor that will allow you to quickly get started and become familiar with the process. 您是否正在寻找一种轻松创建自己的网页的方法&#…

电脑pin重置_如果忘记了如何重置Windows PIN

电脑pin重置A good password or PIN is difficult to crack but can be difficult to remember. If you forgot or lost your Windows login PIN, you won’t be able to retrieve it, but you can change it. Here’s how. 好的密码或PIN很难破解&#xff0c;但很难记住。 如果…

android.support不统一的问题

今天supprt28遇到的问题&#xff0c;由于28还是预览版&#xff0c;还存在一些bug 都是因为如果程序内出现不同的&#xff0c;support或者其他外部引用库的多个版本&#xff0c;Gradle在进行合并的时候会使用本地持有的&#xff0c;最高版本的来进行编译&#xff0c;所以25的sup…

轻松查看Internet Explorer缓存文件

Sometimes you may need a quick and easy way to access Internet Explorer’s cache. Today we take a look at IECacheView which is a great application to get the job done. 有时&#xff0c;您可能需要一种快速简便的方法来访问Internet Explorer的缓存。 今天&#xf…

latex插入gif_如何将照片和GIF插入Google幻灯片

latex插入gifUsing text (and only text) in your Google Slides presentation is a great way to lose the attention of your audience. Inserting photos and animated GIFs can immediately spice things up by emphasizing the important points you make. 在Google幻灯片…

springboot入门(一)--快速搭建一个springboot框架

原文出处 前言在开始之前先简单介绍一下springboot&#xff0c;springboot作为一个微框架&#xff0c;它本身并不提供Spring框架的核心特性以及扩展功能&#xff0c;只是用于快速、敏捷地开发新一代基于Spring框架的应用程序&#xff0c;总的来说springboot不是为了要替代Sprin…

q-dir 打不开文件_Q-Dir –多窗格文件管理器

q-dir 打不开文件Sometimes when looking through a file manager, it would be nice to have more than a dual-pane view. Now you can manage your files with up to four viewing panes at once with Q-Dir. 有时&#xff0c;在查看文件管理器时&#xff0c;拥有多个双窗格…

windows10加载动画_如何关闭动画并使Windows 10看起来更快

windows10加载动画Windows 10 fades and window animations are pure eye candy, but waiting for them to load can make your PC seem a bit slow. If you’d like an instant response, you can disable Windows 10’s animations for a snappier desktop experience. Windo…

JData大数据竞赛18年赛题-如期而至-用户购买时间预测

年前做的&#xff0c;也是学习别人的作品作为记录 一、赛题 表1&#xff1a;sku基本信息表&#xff08;jdata_sku_basic_info&#xff09; 表2&#xff1a;用户基本信息表&#xff08;jdata_user_basic_info&#xff09; 表3&#xff1a;用户行为表&#xff08;jdata_user_acti…

LNMP架构(二)

2019独角兽企业重金招聘Python工程师标准>>> 一 Nginx安装 1、切换目录 # cd /usr/local/src 2、下载 # wget http://nginx.org/download/nginx-1.12.1.tar.gz 3、解压 # tar xzvf nginx-1.12.1.tar.gz 4、切换到nginx目录下 # cd nginx-1.12.1/ 5、编译 # ./confi…

edge无法上网dns_如何在Microsoft Edge中通过HTTPS启用DNS

edge无法上网dnsMicrosoft will one day enable DNS over HTTPS (DoH) for all Windows applications, but you can enable it in the new version of Microsoft Edge today with a hidden flag. DoH will improve your security and privacy online, but it isn’t yet enable…

satis原理浅析

什么是satis 我们一般是从packagist获取composer包的&#xff0c;但这些都是公开的。那如果我们想创建自己的私有库呢&#xff0c;比如企业就会有这方便的需要&#xff0c;那我们就可以用satis来创建自己的私有库。 Satis 是一个静态的 composer 资源库生成器。它像是一个超轻量…

c#写字板实现加粗功能_Windows 7中写字板和绘画中的新功能

c#写字板实现加粗功能WordPad and Paint are often overlooked accessories included in all versions of Windows since 95. They are still included in Windows 7 and now have a new look with some enhanced features. Here we will take a look at some of the new impro…

浏览器加载静态资源文件异常解决办法

2019独角兽企业重金招聘Python工程师标准>>> 1 使用chrome浏览器加载静态资源文件(css、js等)异常导致cssh和js文件不生效&#xff0c;具体报错如下: Resource interpreted as Stylesheet but transferred with MIME type text/html 原因应该是网页文档类型不一致导…

用Emesene替换Windows Live Messenger

Tired of Windows Live Messenger bloat and wishing that there was a simpler and cleaner replacement that would let you use your live.com and hotmail.com accounts? Look no further, now you can have all that messenger goodness with Emesene! 厌倦了Windows Liv…

myeclipse和maven的clean和build

转&#xff1a; 详解myeclipse和maven的clean和build 2018年04月20日 11:33:34 群星坠 阅读数&#xff1a;3529 版权声明&#xff1a;本文为博主原创文章&#xff0c;未经博主允许不得转载。 https://blog.csdn.net/qq_35603331/article/details/80002723MyEclipse是一个被广为…

三星Galaxy S20:如何开启黑暗模式

Justin Duino贾斯汀杜伊诺(Justin Duino)Samsung was one of the first Android manufacturers to add Dark Mode to its handsets. If you recently purchased a Galaxy S20, S20, or S20 Ultra, enabling the UI feature and setting it up on a schedule is extremely easy.…

nginx和apache限制IP地址访问的设置方法

一、nginx禁止IP地址访问1、在nginx配置文件中加入这个&#xff1a;2、重启nginx服务二、apache禁止IP地址访问1、更改vhosts.conf文件&#xff1a;NameVirtualHost 192.168.1.191 <VirtualHost 192.168.1.191:99>#DocumentRoot "/usr/local/kk-mail/data/www"…

wordweb在线编辑_使用WordWeb享受按需词典和词库功能

wordweb在线编辑Run across an unusual word or need a synonym for a word quickly? Usually that means opening a browser and doing the appropriate search. Now you can have all that word power goodness at your fingertips with WordWeb. 遇到一个不寻常的词还是需…