zoukankan      html  css  js  c++  java
  • 抓老鼠啊

    一、实验代码:

    include <stdio.h>

    int main () {
    int unhappy = 0, sad = 0, happy = 0, profit = 0;
    char c;
    while ( ( c = getchar() ) != '$' ) {
    if ( unhappy && !happy ) {
    printf("-");
    --unhappy;
    }
    else if ( sad && !happy ) {
    printf("-");
    --sad;
    }
    else {
    if ( happy )
    --happy;
    if ( c == 'T' ) {
    printf("D");
    sad = 2;
    profit += 7;
    }
    else if ( c == 'C' ) {
    printf("!");
    happy = 2;
    profit -= 3;
    }
    else {
    printf("U");
    unhappy = 1;
    }
    }
    }
    printf(" %d", profit);
    return 0;
    }
    二、设计思路
    1:按照题中给的意思与字母给出 并定义其中的变量
    2:利用if-else语句来变化
    三、截图
    {{uploading-image-289299.png(uploading...)}}

  • 相关阅读:
    poj2679
    poj2709
    poj1521
    poj2054
    静脉曲张病案
    眩晕耳鸣病案
    声嘶治验
    甘露消毒丹治疗高热不退一例
    黄芩汤加减治疗腹痛一例
    自残症治愈案
  • 原文地址:https://www.cnblogs.com/zhouhuahua/p/10400401.html
Copyright © 2011-2022 走看看