本文整理汇总了C++中display_list函数的典型用法代码示例。如果您正苦于以下问题:C++ display_list函数的具体用法?C++ display_list怎么用?C++ display_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了display_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
printf("Let us formulate the problem statement to understand the deletion process. Given a key, delete the first occurrence of this key in linked list.\nTo delete a node from linked list, we need to do following steps.\n1) Find previous node of the node to be deleted.\n2) Changed next of previous node.\n3) Free memory for the node to be deleted.\nSince every node of linked list is dynamically allocated using malloc() in C, we need to call free() for freeing memory allocated for the node to be deleted.\n");
//struct node *head = NULL;
//head = (struct node*)malloc(sizeof(_node));
_node *head = NULL;
insert_element(&head,1);
insert_element(&head,2);
display_list(head);
// printf(" number of nodes = %d");
insert_element(&head,7);
insert_element(&head,8);
insert_element(&head,9);
insert_element(&head,12);
insert_element(&head,111);
display_list(head);
//delete_node(&head,111);
display_list(head);
insert_element(&head,13);
insert_element(&head,15);
//head->next->next->next->next->next->next = head->next->next;
int give_answer = detect_loop(head);
//delete_node(&head,1);
//display_list(head);
//delete_node(&head,12);
//display_list(head);
//delete_node(&head,8);
//display_list(head);
return 0;
}
开发者ID:vdahiya,项目名称:practice_problems,代码行数:30,代码来源:ll2.c
示例2: quick_sort
void quick_sort (int l[], int left, int right) {
int i, pivot;
/* do nothing if array contains fewer than two elements */
if(left >= right)
return;
/* partition and move pivot element to v[0] */
swap(l, left, (left+right)/2);
display_list(l, SIZE);
pivot = left;
printf("Pivot: %d\n", l[pivot]);
/*scan all items from pivot+1 */
for (i=left+1; i<=right; i++)
if (l[i] < l[left]) {
printf("Compared for Swap: %d %d\n", l[i], l[left]);
swap (l, ++pivot, i);
display_list(l, SIZE);
}
swap(l, left, pivot);
display_list(l, SIZE);
printf("Recursion Starts\n");
quick_sort (l, left, pivot-1);
quick_sort (l, pivot+1, right);
}
开发者ID:kushalkoolwal,项目名称:c_programs,代码行数:25,代码来源:sorting_func.c
示例3: main
/*
* Main method that runs operations - doesn't return values
* Reads in 3 lines: Operations, first numeric string, second numeric string
* Usage: reads in from stdin non-negative numeric strings to do addition or subtraction operations
*/
int main( void ){
size_t op_size = 4; // max add or
size_t line_size = 80; // Temporary size
char *op, *first, *second, *first_cpy, *second_cpy, *result;
// Cant allocate space
if( !(op = calloc(op_size, sizeof(char))) || !(first = calloc(line_size, sizeof(char))) || !(second = calloc(line_size, sizeof(char)))){
fprintf(stderr, "Error: Allocating memory\n");
return 1;
}
getline(&op, &op_size, stdin); // Gets the operator
if((strcmp(op, "add\n") == 0) || (strcmp(op, "sub\n") == 0)){ // Not accepted string
getline(&first, &line_size, stdin); // reads in first numeric string
first_cpy = input(first);
free(first); // already have copy now
if(first_cpy == NULL){
free(op);
return 1;
}
getline(&second, &line_size, stdin); // reads in second numeric string
second_cpy = input(second);
free(second); // already have copy now
if(second_cpy == NULL){
free(op);
free(first_cpy);
return 1;
}
int result_size = (strlen(first_cpy) >= strlen(second_cpy)) ? (strlen(first_cpy)) : strlen(second_cpy);
if(!(result = calloc(result_size + 1, sizeof(char)))){ // 1 more in case has carry or negative
fprintf(stderr, "Error: Creating memory\n");
return 1;
}
if(strcmp(op, "add\n") == 0){ // Doing add operation
int add_status = 0;
if((add_status = add(first_cpy, second_cpy, result)) == 1){
printf("1");
display_list(result);
}else if(add_status == 0){ display_list(result);}
}else{ // subtraction
int sub_status = 0;
if((sub_status = sub(first_cpy, second_cpy, result)) == 1){
printf("-");
display_list(result);
}else if(sub_status == 0){ display_list(result); }
}
}else{ // Invalid op operation
fprintf(stderr, "Error: 1st line not equal to 'add' or 'sub'\n");
free(op);
free(first);
free(second);
return 1;
}
free(op);
free(first_cpy);
free(second_cpy);
free(result);
return 0;
}
开发者ID:tmiles,项目名称:c_portfolio,代码行数:62,代码来源:strmath.c
示例4: remove_timer
/**
* Remove a timer from the list of active timers.
*
* @param timerToRemove pointer on the timer to remove
*
* WARNING: timerToRemove MUST NOT be null (rem: static function )
*
*/
static void remove_timer (T_TIMER_LIST_ELT* timerToRemove)
{
T_TIMER_LIST_ELT* removePoint;
#ifdef __DEBUG_OS_ABSTRACTION_TIMER
_log ("\nINFO : remove_timer - start: removing 0x%x to expire at %d (now = %d)", (uint32_t) timerToRemove, timerToRemove->desc.expiration, _GET_TICK());
display_list();
#endif
if ( NULL != g_CurrentTimerHead )
{
removePoint = g_CurrentTimerHead;
while ( NULL != removePoint )
{
if ( timerToRemove == removePoint )
{
if ( NULL != timerToRemove->next )
{
timerToRemove->next->prev = timerToRemove->prev ;
}
if ( NULL != timerToRemove->prev )
{
timerToRemove->prev->next = timerToRemove->next ;
}
}
removePoint = removePoint->next ;
}
if ( timerToRemove == g_CurrentTimerHead )
{
g_CurrentTimerHead = g_CurrentTimerHead->next;
if (NULL != g_CurrentTimerHead) {
g_CurrentTimerHead->prev = NULL;
}
}
}
else
{
#ifdef __DEBUG_OS_ABSTRACTION_TIMER
_log ("\nERROR : remove_timer : list of active timer is empty ");
#endif
panic (E_OS_ERR);
}
/* clean-up links */
timerToRemove->prev = NULL;
timerToRemove->next = NULL;
timerToRemove->desc.status = E_TIMER_READY;
#ifdef __DEBUG_OS_ABSTRACTION_TIMER
_log ("\nINFO : remove_timer - end ");
display_list();
#endif
}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:63,代码来源:timer.c
示例5: main
int main(void) {
struct NODE *llist = (struct NODE*)malloc(sizeof(struct NODE)), *sentinal = (struct NODE*)malloc(sizeof(struct NODE));
int number;
for(number = 1; number < 150; number++){
append_node(llist, number);
}
display_list(llist);
sentinal->next = llist;
delete_node(sentinal, 50);
display_list(llist);
return number;
}
开发者ID:GeorgeOnGit,项目名称:bar,代码行数:13,代码来源:llist.c
示例6: main
//---------main-------------------
int main(){
char end;
int operation;
do{
display_menu();
scanf("%d",&operation);
switch(operation){
case 1 :
display_list();
break;
case 2 :
push();
break;
case 3 :
pop();
break;
default :
printf("Error : Wronge number entered.\n");
break;
}
printf("\n\nDo you want to end program? Enter 'y' or 'n' : ");
end=getche();
printf("\n\n");
}while(end!='y');
}
开发者ID:h4s33b,项目名称:os_simulations,代码行数:29,代码来源:stack.cpp
示例7: main
int main(int argc, char **argv)
{
Node *head = NULL;
char **filenames = init_filenames();
char arg;
char *listfile = "index";
char *namefile = "filenames";
while ((arg = getopt(argc,argv,"i:n:")) > 0){
switch(arg){
case 'i':
listfile = optarg;
break;
case 'n':
namefile = optarg;
break;
default:
fprintf(stderr, "Bad arguments for printindex\n");
exit(1);
}
}
read_list(listfile, namefile, &head, filenames);
display_list(head, filenames);
return 0;
}
开发者ID:KanwarGill,项目名称:SimpleSearchEngine,代码行数:28,代码来源:printindex.c
示例8: insert_after
int insert_after(struct node *newNode)
{
display_list();
printf("\nEnter the no. of element after which you want to insert.\n");
int n;
scanf("%d",&n);
struct node *temp;
temp=head.next;
int r=1;
while(temp!=NULL)
{
if(r!=n)
{
r++;
temp=temp->next;
continue;
}
else
{
if(temp->next==NULL)
{
temp->next=newNode;
newNode->prev=temp;
break;
}
else{
newNode->next=temp->next;
newNode->prev=temp;
temp->next->prev=newNode;
temp->next=newNode;
break;
}
}
}
}
开发者ID:abhinav96,项目名称:doubly-linked-list,代码行数:35,代码来源:doublyLinkedList.c
示例9: main
int main(int ac, char **av)
{
char buffer[2048];
struct termios t;
char read_char[5];
t_l *l;
*read_char = 0;
l = NULL;
if (tgetent(buffer, getenv("TERM")) < 1)
return (-1);
term_no_canon(t);
tputs(tgetstr("ti", NULL), 1, ft_int_putchar);
tputs(tgetstr("vi", NULL), 1, ft_int_putchar);
if ((l = (t_l *)malloc(sizeof(t_l))) == NULL)
return (-1);
ft_init_list(l);
display_list(l, ac, av);
tputs(tgetstr("ks", NULL), 1, ft_int_putchar);
read_keys(read_char);
tputs(tgetstr("ke", NULL), 1, ft_int_putchar);
tputs(tgetstr("ve", NULL), 1, ft_int_putchar);
tputs(tgetstr("te", NULL), 1, ft_int_putchar);
term_canon(t);
return (0);
}
开发者ID:Nquere,项目名称:select,代码行数:26,代码来源:main.c
示例10: main
/*
* Main method that runs all the iterations
* Reads sequence of integers and displays the counts of the value occurance
* Returns 0 is no errors, 1 if run into input, or memory issues
*/
int main( void ){
int status, count;
while((status = scanf("%d",&count)) != EOF){
if(status == 0){ // Initial count is a non-int
fprintf(stderr, "Didn't read any input\n");
return 1;
}
if(count < 1){
fprintf(stderr, "Count must be positive\n");
return 1;
}
int i = 0;
struct occurance *values = NULL;
for(i = 0; i < count; i++){ // Assigns all the values
int value;
if((status = scanf("%d", &value) == 0) || status == EOF){
fprintf(stderr, "Invalid input or too few input\n");
free_list(values);
return 1;
}
values = add(values, value); // adds & updates linked list
}
display_list(values); // Displays occurances
free_list(values); // free in memory
}
return 0;
}
开发者ID:tmiles,项目名称:c_portfolio,代码行数:32,代码来源:count.c
示例11: main
int main()
{
int choice=0;
while(1)
{
printf("\n1.Insert new element\n2.Delete an element\n3.Display linked list\n4.Reverse display\n0.Exit\n");
scanf("%d",&choice);
switch(choice)
{
case 0:return 0;
case 1:
{
create_node();
break;
}
case 2:
{
delete_node();
break;
}
case 3:
{
display_list();
break;
}
case 4:
{
reverse_display();
break;
}
default:printf("\nWrong choice selected.Try again\n");
}
}
}
开发者ID:abhinav96,项目名称:doubly-linked-list,代码行数:34,代码来源:doublyLinkedList.c
示例12: ask_position
int ask_position(struct node *newNode)
{
printf("\nThe linked list is ");
int check=display_list();
if(check==1)
{
printf("\nThe inserted element becomes the first element\n");
head.next=newNode;
}
else
{
printf("\nEnter a choice\n1.Insert after an element\n2.Insert before an element\n");
int choice;
scanf("%d",&choice);
switch(choice)
{
case 1:
{
insert_after(newNode);
break;
}
case 2:
{
insert_before(newNode);
break;
}
default:printf("\nWrong choice.New element not inserted.\n");
}
}
}
开发者ID:abhinav96,项目名称:doubly-linked-list,代码行数:30,代码来源:doublyLinkedList.c
示例13: control_size
int control_size(t_elem *l)
{
char *termtype;
int lin;
termtype = getenv("TERM");
if (!termtype)
ft_env_error();
tgetent(NULL, termtype);
tputs(tgetstr("cl", NULL), 1, int_char);
lin = tgetnum("li");
l->len = ft_list_len(l);
if (l->len > lin - 1)
{
tputs(tgetstr("cl", NULL), 1, int_char);
ft_putendl_red("Please Resize window");
return (0);
}
else
{
tputs(tgetstr("cl", NULL), 1, int_char);
display_list(l);
}
return (1);
}
开发者ID:ThomasSan,项目名称:ft_select,代码行数:25,代码来源:display.c
示例14: printf
node *remove_member(node *head)
{
char ch[20];
node *ptr=NULL,*prev=head;
printf("\t\t\tHere you can remove existing member\n\n");
printf("Name of all members (for reference) :-\n\n");
display_list(head,0);
printf("\n");
while(ptr==NULL)
{
printf("Enter name of member : ");
scanf(" %[^\n]",ch);
ptr=find_user_node(head,ch);
if(ptr==NULL)
printf("User not found !! Try Again !!\n\n");
}
per_tot-=ptr->per;
while(prev->next!=ptr)
prev=prev->next;
if(ptr==head)
head=head->next;
else
prev->next=ptr->next;
free(ptr);
return head;
}
开发者ID:vaibhavdangayachvd,项目名称:C-Programming,代码行数:26,代码来源:Easy+Contry+by+VD.c
示例15: main
void main(){
int m=2,n=3;
struct node *t1=create_node(2);
head=t1;
t1->next=create_node(5);
t1->next->next=create_node(7);
t1->next->next->next=create_node(9);
t1->next->next->next->next=create_node(11);
t1->next->next->next->next->next=create_node(13);
t1->next->next->next->next->next->next=create_node(15);
display_list();
alter_list(m,n);
display_list();
}
开发者ID:raunakkr,项目名称:DS_Algorithms,代码行数:17,代码来源:mnlist.c
示例16: insertion_sort
void insertion_sort (int l[], int size) {
int i, index;
for (i=1; i<size; i++) {
index = i;
printf("index=%d ", index);
/* Keep pushing the index element to the left */
while (index > 0 && (l[index] < l[index-1])) {
swap(l, index, index-1);
display_list(l, SIZE);
index--;
}
printf("List after pass: ");
display_list(l, SIZE);
}
}
开发者ID:kushalkoolwal,项目名称:c_programs,代码行数:17,代码来源:sorting_func.c
示例17: main
int main(void) {
int num = 0;
int input = 1;
int retval = 0;
//struct NODE *llist;
miNodo *llist;
llist = (struct NODE *)malloc(sizeof(struct NODE));
llist->number = 0;
llist->next = NULL;
while(input != 0) {
printf("\n-- Menu Selection --\n");
printf("0) Quit\n");
printf("1) Insert\n");
printf("2) Delete\n");
printf("3) Search\n");
printf("4) Display\n");
scanf("%d", &input);
switch(input) {
case 0:
default:
printf("Goodbye ...\n");
input = 0;
break;
case 1:
printf("Your choice: `Insertion'\n");
printf("Enter the value which should be inserted: ");
scanf("%d", &num);
append_node(llist, num);
break;
case 2:
printf("Your choice: `Deletion'\n");
printf("Enter the value which should be deleted: ");
scanf("%d", &num);
delete_node(llist, num);
break;
case 3:
printf("Your choice: `Search'\n");
printf("Enter the value you want to find: ");
scanf("%d", &num);
if((retval = search_value(llist, num)) == -1)
printf("Value `%d' not found\n", num);
else
printf("Value `%d' located at position `%d'\n", num, retval);
break;
case 4:
printf("You choice: `Display'\n");
display_list(llist);
break;
} /* switch */
} /* while */
free(llist);
return(0);
}
开发者ID:trejoel,项目名称:Ch03,代码行数:58,代码来源:simpleList.c
示例18: display_qvariant
int display_qvariant(char *buf) {
char *orig_buf=buf;
uint32_t type = *((uint32_t*)buf);
type=ntohl(type);
buf+=4;
char null=*buf;
buf++;
if(null) {
//Nothing to do
}
switch(type) {
case 1:
buf+=display_bool(buf);
break;
case 2:
case 3:
buf+=display_int(buf, type);
break;
case 7:
//UTF16 byte
buf+=display_short(buf);
break;
case 8:
buf+=display_map(buf);
break;
case 9:
buf+=display_list(buf);
break;
case 10:
buf+=display_string(buf);
break;
case 11:
buf+=display_stringlist(buf);
break;
case 12:
buf+=display_bytearray(buf);
break;
case 15:
buf+=display_time(buf);
break;
case 16:
buf+=display_date(buf);
break;
case 127:
//User type !
buf+=display_usertype(buf);
break;
case 133:
buf+=display_short(buf);
break;
default:
printf("Unknown QVariant type: %d\n", type);
exit(-1);
break;
};
return buf-orig_buf;
}
开发者ID:fuzzball81,项目名称:QuasselC,代码行数:57,代码来源:display.c
示例19: display_lambda
static void display_lambda(struct StXLambda *lambda, StObject port)
{
St_WriteCString("(lambda ", port);
if (lambda->dotted)
{
size_t len = ST_VECTOR_LENGTH(lambda->vars);
if (len == 1)
{
St_Display(ST_VECTOR_DATA(lambda->vars)[0], port);
}
else
{
St_WriteCString("(", port);
for (size_t i = 0; i < len - 1; i++) {
St_Display(ST_VECTOR_DATA(lambda->vars)[i], port);
St_WriteCString(" ", port);
}
St_WriteCString(". ", port);
St_Display(ST_VECTOR_DATA(lambda->vars)[len], port);
St_WriteCString(")", port);
}
}
else
{
St_WriteCString("(", port);
display_list(lambda->vars, port);
St_WriteCString(")", port);
}
size_t len = ST_VECTOR_LENGTH(lambda->defvars);
if (len != 0)
{
St_WriteCString(" ", port);
}
for (size_t i = 0; i < len; i++) {
St_WriteCString("(define ", port);
St_Display(ST_VECTOR_DATA(lambda->defvars)[i], port);
St_WriteCString(" ", port);
St_Display(ST_VECTOR_DATA(lambda->defvals)[i], port);
St_WriteCString(")", port);
if (i < len - 1)
{
St_WriteCString(" ", port);
}
}
if (ST_VECTOR_LENGTH(lambda->body) != 0)
{
St_WriteCString(" ", port);
}
display_body(lambda->body, port);
St_WriteCString(")", port);
}
开发者ID:masaedw,项目名称:lisp,代码行数:55,代码来源:expression.c
示例20: on_split_clicked
void on_split_clicked(GtkButton * button, gpointer user_data)
{
gint w, h;
view_mode = SPLIT_VIEW;
gtk_widget_show(tree1_w);
gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
if (tree2)
gtk_tree_store_clear(tree2);
display_list();
}
开发者ID:OpenHMR,项目名称:Open-HMR600,代码行数:11,代码来源:gconf.c
注:本文中的display_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论