Esempio n. 1
0
int main(){
	Node head1(3);
	Node n1(2);
	Node n2(1);
	Node n3(5);
	Node n4(6);
	head1.Left=&n1;
	head1.Right=&n3;
	n1.Left=&n2;
	n3.Right=&n4;

	Node head2(9);
	Node n1b(8);
	Node n2b(2);
	Node n3b(10);
	Node n4b(11);
	head2.Left=&n1b;
	head2.Right=&n3b;
	n1b.Left=&n2b;
	n3b.Right=&n4b;

	std::cout << " the median of the two arrays is : " << std::setprecision( 2 )<< arrayMedian(&head1,&head2)<<std::endl;

	return 0;
}
Esempio n. 2
0
File: 034.c Progetto: jameszhan/rhea
int main(void){
	register int index;

	head1();
	head2();
	head3();
	
	for(index = 8; index > 0; index--){
		int stuff;
		for(stuff = 0; stuff <= 6; stuff++){
			printf("%d ", stuff);
		}
		printf("index is now %d\n", index);
	}
}
void RelatedPacketDelegate::drawChevrons(QPainter *painter, const QPoint tail, const QPoint head, int head_size) const
{
    int x_mul = head.x() > tail.x() ? -1 : 1;
    QPoint head_points1[] = {
        head,
        QPoint(head.x() + (head_size * x_mul), head.y() + (head_size / 2)),
        QPoint(head.x() + (head_size * x_mul), head.y() - (head_size / 2)),
    };
    QPoint head2(head.x() + (head_size * x_mul), head.y());
    QPoint head_points2[] = {
        head2,
        QPoint(head2.x() + (head_size * x_mul), head2.y() + (head_size / 2)),
        QPoint(head2.x() + (head_size * x_mul), head2.y() - (head_size / 2)),
    };

    painter->drawPolygon(head_points1, 3);
    painter->drawPolygon(head_points2, 3);
}
 RandomListNode *copyRandomList(RandomListNode *head) {
     vector<RandomListNode*> nodes;
     RandomListNode head2(0), *tail2 = &head2;
     for (RandomListNode *p = head; p; p = p->next) {
         nodes.push_back(p);
     }
     for (RandomListNode* node: nodes) {
         tail2->next = new RandomListNode(node->label);
         tail2 = tail2->next;
         node->next = tail2;
         tail2->random = node->random;
     }
     for (RandomListNode *p = head2.next; p; p = p->next) {
         if (p->random) p->random = p->random->next;
     }
     for (int i = 0; i < int(nodes.size()) - 1; ++i) {
         nodes[i]->next = nodes[i + 1];
     }
     if (nodes.size()) nodes[nodes.size() - 1]->next = nullptr;
     return head2.next;
 }