美团网笔试题目 解答:是不是题目不完整啊,我算的是 3:1 2、一个汽车公司的产品,甲厂占 40%,乙厂占 60%,甲的次品率是 1%,乙的次品率是 2%,现在抽出一件汽车时次品,问是甲生产的可能性 解答:典型的贝叶斯公式,p(甲|废品) = p(甲 废品) / p(废品) = (0
01) /(0
01 + 0
02) = 0
25 3、k 链表翻转,美团网笔试题目
给出一个链表和一个数k,比如链表 123456,k=2,则翻转后 214365,若 k=3,翻转后321654,若 k=4,翻转后 432156,用程序实现 非递归可运行代码: #include #include #include typedef struct node { struct node *next; int data; } node; void createList(node **head, int data) { node *pre, *cur, *new; pre = NULL; cur = *head; while (cur
= NULL) { pre = cur; cur = curnext; } new = (node *)malloc(sizeof(node)); newdata = data; newnext = cur; if (pre == NULL) *head = new; else prenext = new; } void printLink(node *head) { while (headnext
= NULL) { printf(%d , headdata); head = headnext; } printf(%d\n, headdata); } int linkLen(node *head) { int len = 0; while