Have a nice day baby. PEACE & LOVE
1071 小赌怡情
思路: 简单的判断题。
#include<stdio.h>
int main() {
int total, n;
scanf("%d%d", &total, &n);
while(n-- > 0 && total > 0) {
int num1, num2, res, wager;
scanf("%d%d%d%d", &num1, &res, &wager, &num2);
if(wager > total)
printf("Not enough tokens. Total = %d.\n", total);
else if( (num1>num2 && res==0) || (num1<num2 && res==1))
printf("Win %d! Total = %d.\n", wager, total += wager);
else
printf("Lose %d. Total = %d.\n", wager, total -= wager);
}
if(total == 0)
printf("Game Over.");
return 0;
}
1072 开学寄语
思路: 物品编号作下标,可以加快检索速度。
#include<Stdio.h>
#define LEN 10000
int main() {
int n, m, sCount, gCount, gNum[LEN]= {
0};
sCount = gCount = 0;
scanf("%d%d", &n, &m);
for(int i=0; i<m; i++) {
int temp;
scanf("%d", &temp);
gNum[temp] = 1;
}
for(int i=0; i<n; i++) {
char name[5];
int count, temp, flag = 0