当前位置: 代码迷 >> 综合 >> PAT乙级 1071 小赌怡情 (15分)
  详细解决方案

PAT乙级 1071 小赌怡情 (15分)

热度:52   发布时间:2024-01-30 15:42:09.0

PAT乙级 1071 小赌怡情

原题链接
送分题
源码:

#include<stdio.h>
int main()
{int T, K, n1, b, t, n2;scanf("%d %d", &T, &K);for (int i = 0; i < K; i++) {scanf("%d %d %d %d", &n1, &b, &t, &n2);if (t > T) {printf("Not enough tokens. Total = %d.\n", T);}else {if ((n2 > n1) == b) {T = T + t;printf("Win %d! Total = %d.\n", t, T);}else {T = T - t;printf("Lose %d. Total = %d.\n", t, T);if(T<=0){printf("Game Over.");break;}}}}return 0;
}