Beispiel #1
0
int 
main(void)
{
	NODE *p_root = NULL;
	int del_val;

	p_root = creat_list(); /*创建一个非循环单链表,返回根指针*/
	traverse_linkedlist(p_root);	/*遍历链表*/
	
	/*插入新结点*/
	if (0 == sll_insert(&p_root, 19))
	{
		printf("插入节点失败,请重试!");
	}

	printf("插入后的链表");
	traverse_linkedlist(p_root);

	printf("现在节点个数为:%d\n", sll_count_nodes(p_root->link));
	
	/*删除节点*/
	if (sll_remove(&p_root, p_root->link->link, &del_val))
	{
		printf("删除节点成功,被删除的节点的值为:%d\n", del_val);
	}
	
	printf("删除后的链表为:\n");
	traverse_linkedlist(p_root);

	free(p_root);
	return 0;
}
Beispiel #2
0
/******************************************************************************************
*    function   :
*    para       :
*
*    return     :
*    history    :   {2013.7.27 yangyang} create;
*                   {2013.8.8 yangyang}  modify
******************************************************************************************/
void time_module_control()
{

    MYtime mt;
    MYtime *pmt = &mt;

    get_currentime(pmt);    //get current time
    if(mt.minute==10||mt.minute==25||mt.minute==40||mt.minute==55)//the condition to check the file whether exist
    {
        //mt store the check time and then get the time that the file begin to transport
        int year, day, hour, minute;
        minute = mt.minute - 10;
        if( minute == 0 )
        {
            if( ( mt.hour == 0 ) && ( mt.day == 1 ) )
            {
                year = mt.year - 1;
                hour = 24;     //when deal with the time 00:00 ,transfer to 4:00
                if((year%400==0) ||(year%4==0&& year%100!=0))
                    day = R_YEAR;
                else
                    day = P_YEAR;
            }
            else if( mt.hour == 0 )
            {
                year = mt.year;
                day = mt.day-1;
                hour = 24;
            }
            else
            {
                hour = mt.hour;
                year = mt.year;
                day = mt.day;
            }
        }
        else
        {
            year = mt.year;
            day = mt.day;
            hour = mt.hour;
        }

        if( minute % 15 == 0 )
        {
            FILE *fp=fopen("mytest.txt","a+");
            fprintf(fp,"before add the node\n");
            fclose(fp);
            display_downloadlist(downloadList);
            creat_list(year,day,hour,minute,downInfoList);
            fp=fopen("mytest.txt","a+");
            fprintf(fp,"after  add the node\n");
            fclose(fp);
            display_downloadlist(downloadList);
                
        }

    }

}
Beispiel #3
0
void
run_sspath(t_csr *gs, p_list *predecesor, 
		lint source, double delta){
	int i;	
	char f_buf[100];	
	sprintf(f_buf, "./data/log/ori");
	FILE *log = fopen(f_buf, "w");	
	p_list *B = (p_list*)malloc(sizeof(p_list)*1000);		
	for(i=0;i<1000;i++){
		B[i] = (p_list) malloc(sizeof(t_list));
		creat_list(B[i]);
	}
	p_list R = (p_list)malloc(sizeof(t_list));
	p_list S = (p_list)malloc(sizeof(t_list));

	creat_list(R);
	creat_list(S);
	for(i=0;i<gs->v_size;i++)
		gs->vet_info[i].weight = INFINITY;
	//relax source vertex
	add_list_two(B[0], source, 0.0);
	gs->vet_info[source].weight = 0.0;
	lint b_total = 1;
	lint iter = 0;

	//major computing
	while(b_total>0){
		empty(R);	
		while (B[iter]->next!=NULL){
			request(gs, delta, B[iter], R, TYPE_LIGHT);
			remember(B[iter], S, &b_total);
			relax(gs, predecesor, B, R, delta, &b_total);
			//DPRINTF(1, "finished relax\n");
		}
		request(gs, delta, S, R, TYPE_HEAVY);
		relax(gs, predecesor, B, R, delta, &b_total);
		print_B(B, log, iter);
		//printf("=================iter %ld\n", iter);
		iter++;
		//DPRINTF(1, "finished iteration %lld \n", iter);
	}
	//DPRINTF(1, "iterations taken %lld\n", iter);	
	//for(i=0;i<gs->v_size;i++)
	//	DPRINTF(1, "vertex %lld %f\n", (i+1), gs->vet_info[i].weight);
	//DPRINTF(1, "\n");
}
Beispiel #4
0
/*
**主函数
*/
int main (void)
{
    int choice;
    struct student * head, * phead;
    struct student * p1;
    printf("\033[36;m");
    menu();
    scanf ("%d",&choice);
    while (choice != 0)
    {
        switch (choice )
        {
            case 1:
                head = creat_list ();
              printf("录入完毕,任意键返回\n");
                clear_s();
            break;
            case 2:
                 print_list (head);
              printf ("输出完毕,任意键返回\n");
                clear_s();
            break;
            case 3:
                delete_list(head);
                if (head == NULL)
                {
                 printf ("删除不成功,请选择:\n");
                    scanf ("%d",&choice);
                    break;
                }
              printf ("删除完毕,任意键返回\n");
                clear_s();
                break;
            case 4:
                 p1 = find_stu(head);
                 print_find(p1);
              printf ("查找完毕,任意键返回\n");
                   clear_s();
                  break;
           case 5:
                 phead = ave_list (head);
                 print_list(phead);
              printf ("排序完毕,任意键返回\n");
                 clear_s();
                 break;
           case 6:
                 head = insert (head);
                 print_list(head);
              printf ("插入完毕,任意键返回\n");
                 clear_s();
                 break;
           case 0:
                 exit (0);
                     break;
          }
        scanf ("%d",&choice);
    }
}
Beispiel #5
0
int		main()
{
  t_obj		*o;
  t_window	w;

  window_init(&w);
  creat_list(&o);
  remp_img(&w, o);
  gere_window(&w);
}
Beispiel #6
0
int main(void)
{
    Link head;
	int flag=0;
	char username[10], choice;
	printf("----------------------学生评教系统-------------------\n");
    printf("请输入用户名:");
	scanf("%s", username);
	printf("请输入密码(六位):");
	//if(secret()==1)
	{
		printf("\n\n\n密码输入正确!!\n\n");
		system("pause");
		system("cls");
		printf("--------------------欢迎登录学生评教系统-------------------\n\n");
		printf("录入学生信息\n");
		head = creat_list();
		printf("按任意键返回主菜单!");
	    getch();
	    fflush(stdin);
		system("cls");
		do
		{
			system("cls");
			printf("-----------------------------------欢迎来到主菜单-------------------------------\n");
			printf("-----------------------------------1.  修改信息---------------------------------\n");
			printf("-----------------------------------2.  删除信息---------------------------------\n");
			printf("-----------------------------------3.   查询   ---------------------------------\n");
			printf("-----------------------------------4.   排序   ---------------------------------\n");
			printf("-----------------------------------5.   打印   ---------------------------------\n");
			printf("-----------------------------------0.  退出系统---------------------------------\n\n\n");

			choice = getch();
			fflush(stdin);
			system("cls");
			switch(choice)
			{
			case '1': changeNode(head);
				break;
			case '2': removeNode(head);
				break;
			case '3':search(head);
				break;
			case '4':sortbynum(head);
				break;
			case '5':print(head);
				break;
			case '0':flag=1;
				break;
			}
		}while(flag!=1);
	}
		system("pause");
		return 0;
}
Beispiel #7
0
int main(int argc, char const *argv[])
{
    int array[10] = {7, 4, 1, 2, 3, 0, 6, 9, 8, 5};
    struct list_node *list = NULL;
    struct list_node *node = NULL;

    list = creat_list(array, 10);
    display_list(list);
    
    node = find_nth2last(list, 2);
    if (node != NULL) {
        printf("nth to last item = %d\n", node->item);
    }

    destory_list(list);

    return 0;
}
Beispiel #8
0
Datei: main.c Projekt: Lu511/-
int main ()
{
    PNODE pHead = NULL; // 等价于 struct Node *pHead = NULL;
    
    int pVal;
    pHead = creat_list(); // 创建一个非循环单链表,并将该链表的头结点的地址付给pHead
//    insert_list(pHead, 2, 6);
    
    delete_list(pHead, 4, &pVal);
    traverse_list(pHead);
//    int len = length_list(pHead);
//    printf("链表的长度是%d\n",len);
//    
//    sort_list(pHead);
//    traverse_list(pHead);
    

    return 0;
}
Beispiel #9
0
int main(void)
{
    int ch;
    list L=creat_list();
    init_from_file(L);
    for(;;)
    {
        CLS;
        main_menu();
        scanf("%d",&ch);
        rst_stdin();
        switch(ch)
        {
        case 1:
            CLS;
            insert_list(L);
            save_to_file(L);
            break;
        case 2:
            CLS;
            print_list(L);
            break;
        case 3:
            CLS;
            serch_list(L);
            break;
        case 4:
            CLS;
            delete_list_menu(L);
            save_to_file(L);
            break;
        case 5:
            CLS;
            update_list_menu(L);
            save_to_file(L);
            break;
        case 0:
            save_to_file(L);
            return 0;
        }
    }
    return 0;
}
Beispiel #10
0
void time_module_control()
{

    MYtime mt;
    MYtime *pmt = &mt;
    int test=-1;
    while(1)
    {
        get_currentime(pmt);    //get current time
        if(mt.minute==10||mt.minute==25||mt.minute==40||mt.minute==55)//the condition to check the file whether exist
        {
            if(test!=mt.minute)
            {
                test=mt.minute;

                if(mt.minute==25&&mt.hour==0)//at the begin of a day ,init the DownloadNode;
                {
                    DownloadNode *p=downloadList->next;
                    DownloadNode *q=p->next;
                    downloadList->next=NULL;
                    while(q!=NULL)
                    {
                        free(p);
                        p=q;
                        q=p->next;
                    }
                    free(p);
                }
                //mt store the check time and then get the time that the file begin to transport
                int year,day,hour,minute;
                minute=mt.minute-10;
                if(minute==0)
                {
                    if(mt.hour==0&&mt.day==1)
                    {
                        year=mt.year-1;
                        hour=24;     //when deal with the time 00:00 ,transfer to 4:00
                        if(year%4==0&&year%100!=0)
                            day=R_year;
                        else
                            day=P_year;
                    }
                    else if(mt.hour==0)
                    {
                        year=mt.year;
                        day=mt.day-1;
                        hour=24;
                    }
                    else
                    {
                        hour=mt.hour;
                        year=mt.year;
                        day=mt.day;
                    }
                }
                else
                {
                    year=mt.year;
                    day=mt.day;
                    hour=mt.hour;
                }
                printf("the file transport time is:%d %d %d:%d\n",year,day,hour,minute);
                if(minute%15==0)
                {
                    //creat the download list
                    creat_list(year,day,hour,minute,downInfoList);
                    #ifdef DEBUG
                    DownloadNode *p=downloadList->next;

                    while(p!=NULL)
                    {
                        printf("%s\n%s\n%s\n\n",p->filename,p->remotePath,p->localPath);
                        //printf("taskNum=%d\n%s\n%s\n",p->taskNum,p->state,p->server->ip);
                        p=p->next;
                    }
                    #endif

                }
            }
        }
    }
}