抓老鼠啊~亏了还是赚了?

include<stdio.h>

int main(void)
{
int a=1,happy=0, unhappy=0,count1=0,count2=0,sad=0;
char c;
scanf("%c",&c);
while(c!='$'){
if(a==1)
switch(c){
case 'X': printf("U");unhappy=1;break;
case 'T': printf("D");sad=2;count1++;count2++;break;
case 'C': printf("!");happy=2;count2++;break;
}
else
printf("-");
if(happy>0) {
happy--;
a=1;
unhappy=0;
sad=0;
}
else if(happy>0&&unhappy>0){
happy--;
unhappy--;
a=1;
}
else if(happy>0&&sad>0){
happy--;
sad--;
a=1;
}
else if (happy<=0&&unhappy>0){

        happy++;
        a=0;
    }
    else if(happy<=0&&sad>0){

        sad--; 
        a=0;
    }
    else if(happy==0&&unhappy==0&&sad==0)
    a=1;
    scanf("%c",&c);
}
printf("
%d",count1*10-count2*3);
return 0;}
原文地址:https://www.cnblogs.com/wuguijunniubi/p/10411012.html