抓老鼠


,1,实验代码
include <stdio.h>
int main (void) {
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("\n%d", profit);
return 0;
},2,设计思路

3,问题。
这个题目对于我来说,太难了
4,pta截图

posted @ 2019-02-21 15:04  Kyrie11  阅读(113)  评论(0)    收藏  举报