本文整理汇总了C++中printlist函数的典型用法代码示例。如果您正苦于以下问题:C++ printlist函数的具体用法?C++ printlist怎么用?C++ printlist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printlist函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
char command;
NodePointer list = NULL;
printf("Online Bookstore Inventory Management Program.\n\nCommands are I (insert), D (delete), S (search by name),\n V (search by rating), P (print), Q (quit).\n");
do
{
printf("\nCommand?: ");
scanf(" %c",&command);
if(command >= 'a' && command <= 'z')
command = command - 'a' + 'A';
if(command == 'I')
list = insert(list);
else if(command == 'D')
list = deletion(list);
else if(command == 'S')
search(list);
else if(command == 'V')
rate(list);
else if(command == 'P')
printlist(list);
else if(command == 'Q')
{
list = quit(list);
printlist(list);
return 0;
}
else
printf("Command invalid\n");
}while(1);
return 0;
}
示例2: main
int main()
{
node* head = NULL;
int numtoinsert;
push(&head,3);
push(&head,99);
push(&head,32);
push(&head,13);
push(&head,30);
printf("before inserting....\n");
printlist(head);
printf("Enter number where you want to insert\n");
scanf("%d",&numtoinsert);
insert(&head,numtoinsert);
printf("after inserting\n");
printlist(head);
return 0;
}
示例3: main
/*
application's main
//*/
int main()
{
element_t* first = NULL;
element_t* last = first;
global_list_size = 0;
// alloc
puts("alloc");
alloclist((void*) &first, (void*) &last);
printf("\n");
// output
puts("elements - before");
printlist(first);
printf("\n");
puts("sorting");
sort((void*) &first);
printf("\n");
puts("elements - after");
printlist(first);
printf("\n");
// free
puts("free");
freelist((void*) &first);
printf("\n");
// exit
puts("READY.");
exit(EXIT_SUCCESS);
}
示例4: main
int main()
{
int *nums1,*nums2;
int m,n;
m=1;
n=6;
nums1=(int *)malloc(sizeof(int) * (m+n));
nums2=(int *)malloc(sizeof(int) * n);
for(int i=0;i<m;i++)
{
*(nums1+i)=(i+2)*10;
}
for(int i=0;i<n;i++)
{
*(nums2+i)=(i+3)*10+5;
}
printf("array 1 is :");
printlist(nums1,m);
printf("array 2 is :");
printlist(nums2,n);
merge(nums1,m,nums2,n);
printf("last is :");
for(int i=0;i<m+n;i++)
{
printf("%d,",*(nums1+i));
}
printf("\n");
}
示例5: testreversealternatenodes
void testreversealternatenodes()
{
struct node* node = buildlistinsortedorder(10);
printlist(node, "node");
node = reversealternateknodes(node, 3);
printlist(node, "node after alternate reverse by k");
}
示例6: testrevbygivensize
void testrevbygivensize()
{
struct node* node = buildlistinsortedorder(10);
printlist(node, "node");
node = reversebyknodes(node, 1);
printlist(node, "after reversing by given size");
}
示例7: testdeletealternatenodes
void testdeletealternatenodes()
{
struct node* node = buildlistattailbyref(10);
printlist(node, "node");
deletealternatenodes(node);
printlist(node, "node after deleting alternate nodes");
}
示例8: main
int main()
{
struct ListNode *p1,*p2,*head;
for(int i=0;i<2;i++)
{
if(i ==0)
{
p1=(struct ListNode *)malloc(sizeof(struct ListNode));
p1->val=i;
p1->next=NULL;
head=p1;
}
else
{
p2=(struct ListNode *)malloc(sizeof(struct ListNode));
p2->val=i;
p2->next=NULL;
p1->next=p2;
p1=p1->next;
}
}
printf("origin:");
printlist(head);
p2=reverseList(head);
printf("after:");
printlist(p2);
}
示例9: main
int main(int argc, char** argv)
{
int i;
int sz = atoi(argv[1]);
int element = atoi(argv[2]);
srand( (unsigned)time( NULL ));
IntVectorPtr vector = VecNew(initialCapacity);
for(i=0;i<sz+1;i++)
vector = VecAdd(vector,rand()%100);
printlist(vector, sz);
if (argc == 3)
{
VecQuickSort(vector);
printf("\nThe position of the number %d is %d\n", element, VecBinarySearch(vector, element));
} else if ( strcmp(argv[3], "-l") == 0 )
{
VecQuickSort2(vector, 1, sz-1);
printf("\nThe position of the number %d is %d\n", element, VecBinarySearch2(vector->data, 0, sz, element));
}
printlist(vector, sz);
VecDelete(vector);
return 0;
}
示例10: main
int main(void){
struct node* head;
struct node* second;
struct node* end;
head=malloc(sizeof(struct node));
second=malloc(sizeof(struct node));
end=malloc(sizeof(struct node));
head->data=1;
head->next=second;
second->data=2;
second->next=end;
end->data=3;
end->next=NULL;
printlist(head);
printf("delete test\n");
if(delete_key(head,5)){
printf("no match with key found. nothing is deleted\n");
}
printlist(head);
return 0;
}
示例11: main
void main()
{ slink *head;
int n,x,i,j;
printf("请输入元素个数");
scanf("%d",&n);
head=creslink(n);
printf("\n");
printlist(head);
printf("\n");
printf("请输入插入的数据元素的值");
scanf("%d",&x);
printf("请输入要在哪个位序之前插入");
scanf("%d",&i);
insert(head, i,x);/*在单链表第i个元素前插入x*/
printf("\n");
printlist(head);/*输出单链表中结点的元素值*/
printf("请输入删除的数据元素的位序");
scanf("%d",&i);
j=Delete(head,i, &x);
printf("\n");
if(j)printf("%d",x);/*删除成功,则输出被删除结点的元素值*/
printf("\n");
printf("最终的链表变成:");
printlist(head);/*输出单链表中结点的元素值*/
turn(head);
printf("原地逆转后的链表变成:");
printlist(head);/*输出单链表中结点的元素值*/
}
示例12: main
int main()
{
char ch[10],num[5];
LinkList head;
head=CreatList();
printlist(head);
printf(" Delete node (y/n):");
scanf("%s",num);
if(strcmp(num,"y")==0||strcmp(num,"Y")==0)
{
printf("Please input Delete_data:");
scanf("%s",ch);
DeleteList(head,ch);
printlist(head);
}
printf("Add node ? (y/n): ");
scanf("%s",ch);
if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
{
head=AddNode(head);
}
printlist(head);
system("pause");
DeleteAll(head);
}
示例13: main
int main(int argc, const char * argv[]){
int d[8]={4,3,6,2,1,5};
printlist(d,6);
// Insert_Sort_Better(d,6);
// printlist(d,6);
// Insert_Shell_Sort(d,6);
// printlist(d,6);
// Bubble_Sort(d,6);
// printlist(d,6);
// Bubble_Sort2(d,6);
// printlist(d,6);
// MergeSort(d,6);
// printlist(d,6);
// Quick_Sort(d,0,5);
// printlist(d,6);
// Select_Sort(d,6);
// printlist(d,6);
MakeMinHeap(d,6);
MinheapsortTodescendarray(d,6);
printlist(d,6);
}
示例14: testrevrecur
void testrevrecur()
{
struct node* node = buildlistinsortedorder(10);
printlist(node, "node");
revrecur(&node);
printlist(node, "after reversing");
}
示例15: testmergesort
void testmergesort()
{
struct node* node = buildlistattailbyref(20);
printlist(node, "node before sorting");
mergesort(&node);
printlist(node, "node after sorting");
}