Beispiel #1
0
int main()
{
	Student stu[10000];               
	int i;
	for(i=0;i<10000;i++)
	{
		stu[i].num=0;
	}
	int type;
	do
	{
	readdate(stu);
	printf("\n请输入序号选择相应功能\n");
	printf("******** 1.显示基本信息 ********\n");
	printf("******** 2.基本信息管理 ********\n");
	printf("******** 3.学生成绩管理 ********\n");
	printf("******** 4.考试成绩统计 ********\n");
	printf("******** 5.根据条件查询 ********\n");
	printf("******** 0.退出         ********\n");
		scanf("%d",&type);
	    switch(type)
		{
		case 0:printf("");break;
		case 1:printbase(stu);break;
		case 2:managebase(stu);break;
		case 3:managescore(stu);break;
		case 4:rankscore(stu);break;
		case 5:checkbase(stu);break;
		default:printf("没有该选项,请重输");break;
		}
	}while(type!=0);
	return 0;
}
Beispiel #2
0
int commandline(int argc, char *argv[], int firstarg) {
	int c;
	unsigned int i;
	char *s;

	while (firstarg < argc && argv[firstarg][0] == '-') { /* command flags */
		for(i=1; i < strlen(argv[firstarg]); i++) {
			if ((c = argv[firstarg][i]) == '\0') break;
			else if (decodeflag(c) != 0) { /* flag takes argument */
				if ((s = strchr(argv[firstarg], '=')) == NULL) {
					firstarg++; s = argv[firstarg];
				}
				else s++;
				if (startflag) {
					if (c >= 'A' && c <= 'Z') startchar = c;
					else if (c >= 'a' && c <= 'z') startchar = c - 'a' + 'A';
					startflag=0;
				}
				else if (endflag) {
					if (c >= 'A' && c <= 'Z') endchar = c;
					else if (c >= 'a' && c <= 'z') endchar = c - 'a' + 'A';
					endflag=0;
				}
				else if (dateflag) {
					threshold = s;
					readdate(threshold);
					makenewtime ();
					thresholdflag = 1;
					dateflag=0;
				}
				else if (outflag) {
					destination = s;
					outflag=0;
				}
				break;
			}
		}
		firstarg++;
	}
	return firstarg;
}
Beispiel #3
0
static VALUE
rb_rcsrev_new(struct rcsrev *rev)
{
	struct tm tm;
	const char *month;
	VALUE self;
	VALUE date;

	memset(&tm, 0, sizeof(tm));
	if (rev->date->len == 17) {
		/* 2-digit year */
		readdate(rev->date->str, &tm.tm_year, 2);
		month = rev->date->str + 3;
	} else {
		/* 4-digit year */
		readdate(rev->date->str, &tm.tm_year, 4);
		tm.tm_year -= 1900;
		month = rev->date->str + 5;
	}

	readdate(month, &tm.tm_mon, 2);
	tm.tm_mon--;
	readdate(month + 3, &tm.tm_mday, 2);
	readdate(month + 6, &tm.tm_hour, 2);
	readdate(month + 9, &tm.tm_min, 2);
	readdate(month + 12, &tm.tm_sec, 2);
	date = rb_time_new(timegm(&tm), 0);
	/*
	 * rb_time_new returns a Time object in local time, so convert
	 * it to GMT, what RCS/CVS uses everywhere.
	 */
	date = rb_funcall(date, rb_intern("gmtime"), 0);

	self = rb_obj_alloc(rb_cRev);
	rb_iv_set(self, "@rev", str_from_tok(rev->rev));
	rb_iv_set(self, "@date", date);
	rb_iv_set(self, "@author", str_from_tok(rev->author));
	rb_iv_set(self, "@state", str_from_tok2(rev->state));
	rb_iv_set(self, "@branches", ary_from_toklist(&rev->branches));
	rb_iv_set(self, "@next", str_from_tok2(rev->next));
	rb_iv_set(self, "@commitid", str_from_tok2(rev->commitid));
	return self;
}
Beispiel #4
0
int main(void)
{
    FILE* f;
    char str[MS];
    int k;
    struct mylist* head=NULL, *head1 = NULL, *headr=NULL, *headr1=NULL, *kwn, *cir, *cir1;
    struct anime* mas=NULL, *mas1=NULL, *masr = NULL, *masr1 = NULL;
    setlocale(0, "russian");

    printf("Тестирование функции readline из mystruct.c\n");
    f = fopen("testread/test1.txt","r");
    k = freadline(f, str, MS);
    if (strcmp(str, "bbbb") == 0 && k == 4)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    fclose(f);

    f = fopen("testread/test2.txt","r");
    k = freadline(f, str, MS);
    if (strcmp(str, "bbbbb") == 0 && k == 5)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    fclose(f);

    f = fopen("testread/test3.txt","r");
    k = freadline(f, str, MS);
    if (strcmp(str, "aba aba b") == 0 && k == 9)
        printf("\nTest 3 - OK!");
    else
        printf("\nTest 3 - FAILED!");
    fclose(f);

    f = fopen("testread/test4.txt","r");
    k = freadline(f, str, MS);
    if (strcmp(str, "trata trata") == 0 && k == 11)
        printf("\nTest 4 - OK!");
    else
        printf("\nTest 4 - FAILED!");
    fclose(f);

    f = fopen("testread/test5.txt","r");
    k = freadline(f, str, MS);
    if (strcmp(str, "") == 0 && k == 0)
        printf("\nTest 5 - OK!");
    else
        printf("\nTest 5 - FAILED!");
    fclose(f);

    f = fopen("testread/test6.txt","r");
    k = freadline(f, str, 3);
    if (strcmp(str, "AA") == 0 && k == 2)
        printf("\nTest 6 - OK!");
    else
        printf("\nTest 6 - FAILED!");
    fclose(f);



    printf("\n\nТестирование функции readdate из mystruct.c\n");
    mas = malloc(sizeof(struct anime));
    f = fopen("testread/test_d.txt","r");
    readdate(f, mas);
    if (strcmp(mas->name, "One Punch Man") == 0 && strcmp(mas->stud, "Madhouse") == 0 && mas->year==2015)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    readdate(f, mas);
    if (strcmp(mas->name, "Overlord") == 0 && strcmp(mas->stud, "Mad House") == 0 && mas->year==2014)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    fclose(f);
    free(mas);  mas = NULL;


    printf("\n\nТестирование функции readfile из mystruct.c\n");
    mas = NULL;
    f = fopen("testread/test_d.txt","r");
    mas = readfile(f, &k);
    if (strcmp(mas->name, "One Punch Man") == 0 && strcmp(mas->stud, "Madhouse") == 0 && mas->year==2015 && k == 2 &&
        strcmp((mas+1)->name, "Overlord") == 0 && strcmp((mas+1)->stud, "Mad House") == 0 && (mas+1)->year==2014)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    free(mas);  mas = NULL;
    fclose(f);
    mas = NULL;
    f = fopen("testread/test_de.txt","r");
    mas = readfile(f, &k);
    if (mas == NULL && k == 0)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    free(mas);  mas = NULL;
    fclose(f);


    printf("\n\nТестирование функции formlist из mystruct.c\n");
    mas = NULL;
    f = fopen("testread/test_d.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    if (strcmp(((struct anime*) head->date)->name, "One Punch Man") == 0 && strcmp(((struct anime*) head->date)->stud, "Madhouse") == 0 && ((struct anime*) head->date)->year==2015 && k == 2 &&
        strcmp(((struct anime*) head->next->date)->name, "Overlord") == 0 && strcmp(((struct anime*) head->next->date)->stud, "Mad House") == 0 && ((struct anime*) head->next->date)->year==2014)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    free_list(head); head = NULL;
    free(mas);  mas = NULL;
    fclose(f);

    mas = NULL;
    head = NULL;
    f = fopen("testread/test_de.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    if (head == NULL)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    free_list(head); head = NULL;
    free(mas);  mas = NULL;
    fclose(f);

    printf("\n\nТестирование функции namecmp из mystruct.c\n");
    mas = malloc(2*sizeof(struct anime));
    snprintf(mas->name, MS, "AAA");
    snprintf(mas->stud, MS, "A");
    mas->year = 0;
    snprintf((mas+1)->name, MS, "BBB");
    snprintf((mas+1)->stud, MS, "A");
    mas->year = 0;
    head = create_mylist(mas);
    head1 = create_mylist(mas+1);
    if (namecmp(head, head1) < 0)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    snprintf(mas->name, MS, "CCC");
    if (namecmp(head, head1) > 0)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    snprintf((mas+1)->name, MS, "CCC");
    if (namecmp(head, head1) == 0)
        printf("\nTest 3 - OK!");
    else
        printf("\nTest 3 - FAILED!");
    free(mas);  mas = NULL;
    mas = NULL;
    free(head);
    head = NULL;
    free(head1);
    head1 = NULL;

    printf("\n\nТестирование функции lookup из exfunclo.c\n");
    mas1 = malloc(sizeof(struct anime));
    snprintf(mas1->name, MS, "AAABBB");
    snprintf(mas1->stud, MS, "AAA");
    mas1->year = 24;

    head1 = create_mylist(mas1);
    f = fopen("testlook/test1.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    if (lookup(head, head1, namecmp) != NULL)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    free_list(head); head = NULL;
    head = NULL;
    free(mas);  mas = NULL;
    mas = NULL;
    fclose(f);
    free(head1);
    head1 = create_mylist(mas1);
    f = fopen("testlook/test2.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    if (lookup(head, head1, namecmp) != NULL)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    free_list(head); head = NULL;
    head = NULL;
    free(mas);  mas = NULL;
    mas = NULL;
    fclose(f);
    f = fopen("testlook/test3.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    if (lookup(head, head1, namecmp) != NULL)
        printf("\nTest 3 - OK!");
    else
        printf("\nTest 3 - FAILED!");
    free_list(head); head = NULL;
    head = NULL;
    free(mas);  mas = NULL;
    mas = NULL;
    fclose(f);
    f = fopen("testlook/test4.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    if (lookup(head, head1, namecmp) == NULL)
        printf("\nTest 4 - OK!");
    else
        printf("\nTest 4 - FAILED!");
    free_list(head); head = NULL;
    head = NULL;
    free(mas);  mas = NULL;
    mas = NULL;
    fclose(f);
    f = fopen("testlook/test5.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    if (lookup(head, head1, namecmp) == NULL)
        printf("\nTest 5 - OK!");
    else
        printf("\nTest 5 - FAILED!");
    free_list(head); head = NULL;
    head = NULL;
    free(mas);  mas = NULL;
    mas = NULL;
    fclose(f);

    printf("\n\nТестирование функции insert из exfunclo.c\n");
    f = fopen("testins/test1.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testins/test11.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    insert(&head, head1);
    int s = 0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    free_list(head); head = NULL;
    free(mas);  mas = NULL;
    free_list(headr); headr = NULL;
    free(masr);  masr = NULL;
    free(mas1);  mas1 = NULL;
    mas1 = malloc(sizeof(struct anime));
    snprintf(mas1->name, MS, "AAABBB");
    snprintf(mas1->stud, MS, "AAA");
    mas1->year = 24;
    head1 = create_mylist(mas1);
    f = fopen("testins/test1.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testins/test12.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    kwn = head->next->next->next;
    insert(&kwn, head1);
    s = 0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    free_list(head); head = NULL;
    free(mas);  mas = NULL;
    free_list(headr); headr = NULL;
    free(masr);  masr = NULL;
    free(mas1);  mas1 = NULL;

    f = fopen("testins/test2.txt","r");
    mas1 = malloc(sizeof(struct anime));
    snprintf(mas1->name, MS, "AAABBB");
    snprintf(mas1->stud, MS, "AAA");
    mas1->year = 24;
    head1 = create_mylist(mas1);
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    insert(&head, head1);
    if (allcmp(head, head1) == 0 && head->next == NULL)
        printf("\nTest 3 - OK!");
    else
        printf("\nTest 3 - FAILED!");
    free(mas1);  mas1 = NULL;
    free(mas);  mas = NULL;
    free(head); head = NULL;

    printf("\n\nТестирование функции remove_duplicates из exfunclo.c\n");
    f = fopen("testrmd/test1.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testrmd/test1r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    remove_duplicates(head, namecmp);
    s=0;
    if (head == headr && head == NULL)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;

    f = fopen("testrmd/test2.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testrmd/test2r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    remove_duplicates(head, namecmp);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;

    f = fopen("testrmd/test3.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testrmd/test3r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    remove_duplicates(head, namecmp);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("\nTest 3 - OK!");
    else
        printf("\nTest 3 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;

    f = fopen("testrmd/test4.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testrmd/test4r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    remove_duplicates(head, namecmp);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("\nTest 4 - OK!");
    else
        printf("\nTest 4 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;

    printf("\n\nТестирование функции front_back_split из exfunclo.c\n");
    headr = front_back_split(head);
    if (head == NULL && headr == NULL)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");

    f = fopen("testfbs/test1.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testfbs/test1r1.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    f = fopen("testfbs/test1r2.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    head1 = front_back_split(head);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    for (cir = head1, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(mas1); mas1 = NULL;
    free_list(head1); head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testfbs/test2.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testfbs/test2r1.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    f = fopen("testfbs/test2r2.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    head1 = front_back_split(head);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    for (cir = head1, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 3 - OK!");
    else
        printf("\nTest 3 - FAILED");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(mas1); mas1 = NULL;
    free_list(head1); head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testfbs/test3.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testfbs/test3r1.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    f = fopen("testfbs/test3r2.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    head1 = front_back_split(head);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    for (cir = head1, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 4 - OK!");
    else
        printf("\nTest 4 - FAILED");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(mas1); mas1 = NULL;
    free_list(head1); head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;


    printf("\n\nТестирование функции sorted_merge из exfunclo.c");
    f = fopen("testmerge/test1.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testmerge/test1a.txt", "r");
    mas1 = readfile(f, &k);
    head1 = formlist(head1, mas1, k);
    fclose(f);
    f = fopen("testmerge/test1r.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    headr = sorted_merge(head, head1, namecmp);
    s=0;
    for (cir = headr, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 1 - OK!");
    else
        printf("\nTest 1 - FAILED");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(mas1); mas1 = NULL;
    free_list(head1); head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testmerge/test2.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testmerge/test2a.txt", "r");
    mas1 = readfile(f, &k);
    head1 = formlist(head1, mas1, k);
    fclose(f);
    f = fopen("testmerge/test2r.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    headr = sorted_merge(head, head1, namecmp);
    s=0;
    for (cir = headr, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(mas1); mas1 = NULL;
    free_list(head1); head1 = NULL;
    free(masr);  masr = NULL;
    //free_list(headr);
    headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testmerge/test3.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testmerge/test3a.txt", "r");
    mas1 = readfile(f, &k);
    head1 = formlist(head1, mas1, k);
    fclose(f);
    f = fopen("testmerge/test3r.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    headr = sorted_merge(head, head1, namecmp);
    s=0;
    for (cir = headr, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 3 - OK!");
    else
        printf("\nTest 3 - FAILED");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(mas1); mas1 = NULL;
    //free_list(head1);
    head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testmerge/test4.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testmerge/test4a.txt", "r");
    mas1 = readfile(f, &k);
    head1 = formlist(head1, mas1, k);
    fclose(f);
    f = fopen("testmerge/test4r.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    headr = sorted_merge(head, head1, namecmp);
    s=0;
    for (cir = headr, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 4 - OK!");
    else
        printf("\nTest 4 - FAILED");
    free(mas);  mas = NULL;
    //free_list(head);
    head = NULL;
    free(mas1); mas1 = NULL;
    //free_list(head1);
    head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testmerge/test5.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testmerge/test5a.txt", "r");
    mas1 = readfile(f, &k);
    head1 = formlist(head1, mas1, k);
    fclose(f);
    f = fopen("testmerge/test5r.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    headr = sorted_merge(head, head1, namecmp);
    s=0;
    for (cir = headr, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 5 - OK!");
    else
        printf("\nTest 5 - FAILED");
    free(mas);  mas = NULL;
    //free_list(head);
    head = NULL;
    free(mas1); mas1 = NULL;
    //free_list(head1);
    head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testmerge/test6.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testmerge/test6a.txt", "r");
    mas1 = readfile(f, &k);
    head1 = formlist(head1, mas1, k);
    fclose(f);
    f = fopen("testmerge/test6r.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    headr = sorted_merge(head, head1, namecmp);
    s=0;
    for (cir = headr, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 6 - OK!");
    else
        printf("\nTest 6 - FAILED");
    free(mas);  mas = NULL;
    //free_list(head);
    head = NULL;
    free(mas1); mas1 = NULL;
    //free_list(head1);
    head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testmerge/test7.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testmerge/test7a.txt", "r");
    mas1 = readfile(f, &k);
    head1 = formlist(head1, mas1, k);
    fclose(f);
    f = fopen("testmerge/test7r.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    headr = sorted_merge(head, head1, namecmp);
    s=0;
    for (cir = headr, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 7 - OK!");
    else
        printf("\nTest 7 - FAILED");
    free(mas);  mas = NULL;
    //free_list(head);
    head = NULL;
    free(mas1); mas1 = NULL;
    //free_list(head1);
    head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    f = fopen("testmerge/test8.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testmerge/test8a.txt", "r");
    mas1 = readfile(f, &k);
    head1 = formlist(head1, mas1, k);
    fclose(f);
    f = fopen("testmerge/test8r.txt", "r");
    masr1 = readfile(f, &k);
    headr1 = formlist(headr1, masr1, k);
    fclose(f);
    headr = sorted_merge(head, head1, namecmp);
    s=0;
    for (cir = headr, cir1 = headr1; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    s += cir || cir1;
    if (s == 0)
        printf("\nTest 8 - OK!");
    else
        printf("\nTest 8 - FAILED");
    free(mas);  mas = NULL;
    //free_list(head);
    head = NULL;
    free(mas1); mas1 = NULL;
    //free_list(head1);
    head1 = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    free(masr1);  masr1 = NULL;
    free_list(headr1); headr1 = NULL;

    printf("\n\nТестирование функции merge_sort из exfunclo.c\n");
    f = fopen("testbacisort/test1.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testbacisort/test1r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    head =  merge_sort(head, namecmp);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("Test 1 - OK!");
    else
        printf("Test 1 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;

    f = fopen("testbacisort/test2.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testbacisort/test2r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    head =  merge_sort(head, namecmp);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("\nTest 2 - OK!");
    else
        printf("\nTest 2 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;

    f = fopen("testbacisort/test3.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testbacisort/test3r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    head =  merge_sort(head, namecmp);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("\nTest 3 - OK!");
    else
        printf("\nTest 3 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;

    f = fopen("testbacisort/test4.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testbacisort/test4r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    head = merge_sort(head, namecmp);
    s=0;
    if (head == headr && head == NULL)
        printf("\nTest 4 - OK!");
    else
        printf("\nTest 4 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;

    f = fopen("testbacisort/test5.txt","r");
    mas = readfile(f, &k);
    head = formlist(head, mas, k);
    fclose(f);
    f = fopen("testbacisort/test5r.txt", "r");
    masr = readfile(f, &k);
    headr = formlist(headr, masr, k);
    fclose(f);
    head =  merge_sort(head, namecmp);
    s=0;
    for (cir = head, cir1 = headr; cir && cir1; cir = cir->next, cir1 = cir1->next)
        s += allcmp(cir, cir1);
    if (s == 0 && cir == NULL && cir1 == NULL)
        printf("\nTest 5 - OK!");
    else
        printf("\nTest 5 - FAILED!");
    free(mas);  mas = NULL;
    free_list(head); head = NULL;
    free(masr);  masr = NULL;
    free_list(headr); headr = NULL;
    return 0;
}