当前位置: 代码迷 >> 综合 >> Q2.5
  详细解决方案

Q2.5

热度:38   发布时间:2024-01-15 21:24:15.0

编程之美里很tricky的解法明天去看一看

#include <iostream>
using namespace std;typedef struct Node
{char data;struct Node* next;
}Node, *pNode;pNode Init(char* a, int len)
{int i;pNode head, p, q;head = new Node();head->data = a[0];q = head;for (i = 1; i < len; ++i){p = new Node();p->data = a[i];q->next = p;q = p;}q->next = NULL;return head;
}void printList(pNode p)
{while(p){cout<<p->data<<" ";if (p->next){p = p->next;}else{cout<<endl;break;}}
}pNode findCircle(pNode p , int bitmap)
{while(p){if (bitmap & (1 << (p->data - 'A'))){return p;}bitmap |
  相关解决方案