代码改变世界

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

2019-02-21 10:52  小小乌龟君  阅读(178)  评论(0编辑  收藏  举报

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("\n%d",count1*10-count2*3);
return 0;}