解题思路:
(1)注意这里是两个结构体
(2)依次访问,判断是否存在相等
(3)看了别人的解题方法,原来还有一个strchr函数!!!
#include <stdio.h>
#include <stdlib.h>
typedef struct mini_win_t {
char *letters;
unsigned code;
} MiniWin;
typedef struct ticket_t {
MiniWin *mini_wins;
unsigned count;
} Ticket;
const char *bingo(const Ticket *ticket, unsigned win) {
MiniWin *head = ticket->mini_wins;
unsigned count = ticket->count,i = 0,code;
unsigned number = 0;
char *p = NULL;
while(i<count) {
p = head->letters;
code = head->code;
while(*p!='\0') {
if((unsigned)*p==code) {
number++;
break;
} else p++;
}
i++;
head++;
}
if(number>=win) return "Winner!";
else return "Loser!";
}