49861 (Динамическое формирование и преобразование списков и структур), страница 2
Описание файла
Документ из архива "Динамическое формирование и преобразование списков и структур", который расположен в категории "". Всё это находится в предмете "информатика" из 1 семестр, которые можно найти в файловом архиве . Не смотря на прямую связь этого архива с , его также можно найти и в других разделах. Архив можно найти в разделе "курсовые/домашние работы", в предмете "информатика, программирование" в общих файлах.
Онлайн просмотр документа "49861"
Текст 2 страницы из документа "49861"
if(start2==NULL) start2=last2;
p2=p2->next;
}
p=p->next;
}
printf("New list created succesfully! Press any key...");
getch();
end:
return start2;
}
/////////////////////////MAIN FUNCTION////////////////////////////////
void main() {
mg *start, *start2, *last;
int i,n, newn,t=0;
char ans;
clrscr();
for (i=1;i<2;) {
clrscr();
printf("====================MENU=====================\n");
printf("1. Open file\n");
printf("2. Print list of markets\n");
printf("3. Create a new list\n");
printf("4. Print new list of markets\n");
printf("5. Save new list\n");
printf("6. Exit\n\n");
printf("Press 1-6 key. Any other key will exit program");
gotoxy(1, 20);
printf("===============COURSE PROJECT=================\nStudent: Saushkin Pavel Nikolaevich. Group: CBC-31. MIEM 2008");
ans=getch();
switch(ans) {
case '1': {
start=open(last);
if(start!=NULL) t=1;
else if(start->num > 1000 || start->num < 1) {
clrscr();
printf("(!) Error of reading file! Incapable data type! Press any key...");
getch();
break;
}
break;
}
case '2': {
if(t==0) goto err1;
print(start);
break;
}
case '3': {
if(t==0) goto err1;
start2=newlist(start);
t=2;
break;
}
case '4': {
if(t==0) goto err1; else if (t==1) goto err2;
printnew(start2);
break; }
case '5': {
if(t==0) {
err1:
clrscr();
printf("You must open a file! Press any key...");
getch();
break;
} else if (t==1) {
err2:
clrscr();
printf("You must create a new list! Press any key...");
getch();
break;
}
save(start, start2);
break;
}
default: { i=3; }
}
}
-
Тестовые примеры
Содержимое исходного файла (in.dat):
/* Начало файла */
25
Moscow
Lenina
14
butter
17
12.05.08
meat
19
22.07.09
milk
25
17.03.08
eggs
47
07.08.08
juice
12
24.11.08
756
Minsk
Zhukova
52
butter
19
07.04.08
meat
21
29.02.09
milk
23
01.11.09
eggs
33
09.10.08
juice
14
27.08.08
666
Kiev
Gagarina
47
butter
22
12.05.08
meat
29
26.02.09
milk
22
26.07.08
eggs
56
31.10.08
juice
16
02.05.08
748
Petersburg
Pavlovskaya
62
butter
30
19.08.08
meat
27
27.08.09
milk
17
10.03.08
eggs
31
09.08.08
juice
19
30.11.08
33
Volgograd
Potemkina
57
butter
34
10.07.08
meat
29
27.08.09
milk
19
27.03.08
eggs
38
13.02.08
juice
14
16.05.08
/* Конец файла
Работа программы (Пример №1):
1. Open file
2. Print list of markets
3. Create a new list
4. Print new list of markets
5. Save new list
6. Exit
Выбранный пункт меню: 1
Enter path to file to open (ex. C:\\file.txt):
Вводим: d:\in.dat
*File readed successfully! Press any key…*
Возврат в меню.
Выбранный пункт меню: 2
MAGAZINE #25
Address
City: Moscow
Street: Lenina
House: 14
Products
1)
Name: butter
Price: 17
Time: 12.05.08
2)
Name: meat
Price: 19
Time: 22.07.09
3)
Name: milk
Price: 25
Time: 17.03.08
4)
Name: eggs
Price: 47
Time: 07.08.08
5)
Name: juice
Price: 12
Time: 24.11.08
MAGAZINE #756
Address
City: Minsk
Street: Zhukova
House: 52
Products
1)
Name: butter
Price: 19
Time: 07.04.08
2)
Name: meat
Price: 21
Time: 29.02.09
3)
Name: milk
Price: 23
Time: 01.11.09
4)
Name: eggs
Price: 33
Time: 09.10.08
5)
Name: juice
Price: 14
Time: 27.08.08
MAGAZINE #666
Address
City: Kiev
Street: Gagarina
House: 47
Products
1)
Name: butter
Price: 22
Time: 12.05.08
2)
Name: meat
Price: 29
Time: 26.02.09
3)
Name: milk
Price: 22
Time: 26.07.08
4)
Name: eggs
Price: 56
Time: 31.10.08
5)
Name: juice
Price: 16
Time: 02.05.08
MAGAZINE #748
Address
City: Petersbutg
Street: Pavlovskaya
House: 62
Products
1)
Name: butter
Price: 30
Time: 19.08.08
2)
Name: meat
Price: 27
Time: 27.08.09
3)
Name: milk
Price: 17
Time: 10.03.08
4)
Name: eggs
Price: 31
Time: 09.08.08
5)
Name: juice
Price: 19
Time: 30.11.08
MAGAZINE #33
Address
City: Volgograd
Street: Potemkina
House: 57
Products
1)
Name: butter
Price: 34
Time: 10.07.08
2)
Name: meat
Price: 29
Time: 27.08.09
3)
Name: milk
Price: 19
Time: 27.03.08
4)
Name: eggs
Price: 38
Time: 13.02.08
5)
Name: juice
Price: 14
Time: 16.05.08
Any key to next record...
Any key to continue...
Выбранный пункт меню: 3
Enter product’s name:
Вводим meat
*New list created successfully! Press any key…*
Возврат в меню.
Выбранный пункт меню: 4
MAGAZINE #666
Address
City: Kiev
Street: Gagarina
House: 47
Products
1)
Name: butter
Price: 22
Time: 12.05.08
2)
Name: meat
Price: 29
Time: 26.02.09
3)
Name: milk
Price: 22
Time: 26.07.08
4)
Name: eggs
Price: 56
Time: 31.10.08
MAGAZINE #33
Address
City: Volgograd
Street: Potemkina
House: 57
Products
1)
Name: butter
Price: 34
Time: 10.07.08
2)
Name: meat
Price: 29
Time: 27.08.09
3)
Name: milk
Price: 19
Time: 27.03.08
4)
Name: eggs
Price: 38
Time: 13.02.08
5)
Name: juice
Price: 14
Time: 16.05.08
Any key to continue...
Выбранный пункт меню: 5
Enter path to file to write (ex. C:\\file.txt):
Вводим d:\meat.dat
*File created successfully! Press any key…*
Возврат в меню.
Выбранный пункт меню: 6
Работа программы завершена.
Содержимое выходного файла (meat.dat):
/* Начало файла */
25
Moscow
Lenina
14
butter
17
12.05.08
meat
19
22.07.09
milk
25
17.03.08
eggs
47
07.08.08
juice
12
24.11.08
756
Minsk
Zhukova
52
butter
19
07.04.08
meat
21
29.02.09
milk
23
01.11.09
eggs
33
09.10.08
juice
14
27.08.08
666
Kiev
Gagarina
47
butter
22
12.05.08
meat
29
26.02.09
milk
22
26.07.08
eggs
56
31.10.08
juice
16
02.05.08
748
Petersburg
Pavlovskaya
62
butter
30
19.08.08
meat
27
27.08.09
milk
17
10.03.08
eggs
31
09.08.08
juice
19
30.11.08
33
Volgograd
Potemkina
57
butter
34
10.07.08
meat
29
27.08.09
milk
19
27.03.08
eggs
38
13.02.08
juice
14
16.05.08
---------------
666
Kiev
Gagarina
47
butter
22
12.05.08
meat
29
26.02.09
milk
22
26.07.08
eggs
56
31.10.08
juice
16
02.05.08
33
Volgograd
Potemkina
57
butter
34
10.07.08
meat
29
27.08.09
milk
19
27.03.08
eggs
38
13.02.08
juice
14
16.05.08
/* Конец файла
Работа программы (Пример №2):
1. Open file
2. Print list of markets
3. Create a new list
4. Print new list of markets
5. Save new list
6. Exit
Выбранный пункт меню: 1
Enter path to file to open (ex. C:\\file.txt):
Вводим: d:\in.dat
*File readed successfully! Press any key…*
Возврат в меню.
Выбранный пункт меню: 2
MAGAZINE #25
Address
City: Moscow
Street: Lenina
House: 14
Products
1)
Name: butter
Price: 17
Time: 12.05.08
2)
Name: meat
Price: 19
Time: 22.07.09
3)
Name: milk
Price: 25
Time: 17.03.08
4)
Name: eggs
Price: 47
Time: 07.08.08
5)
Name: juice
Price: 12
Time: 24.11.08
MAGAZINE #756
Address
City: Minsk
Street: Zhukova
House: 52
Products
1)
Name: butter
Price: 19
Time: 07.04.08
2)
Name: meat
Price: 21
Time: 29.02.09
3)
Name: milk
Price: 23
Time: 01.11.09
4)
Name: eggs
Price: 33
Time: 09.10.08
5)
Name: juice
Price: 14
Time: 27.08.08
MAGAZINE #666
Address
City: Kiev
Street: Gagarina
House: 47
Products
1)
Name: butter
Price: 22
Time: 12.05.08
2)
Name: meat
Price: 29
Time: 26.02.09
3)
Name: milk
Price: 22
Time: 26.07.08
4)
Name: eggs
Price: 56
Time: 31.10.08
5)
Name: juice
Price: 16
Time: 02.05.08
MAGAZINE #748
Address
City: Petersbutg
Street: Pavlovskaya
House: 62
Products
1)
Name: butter
Price: 30
Time: 19.08.08
2)
Name: meat
Price: 27
Time: 27.08.09
3)
Name: milk
Price: 17
Time: 10.03.08
4)
Name: eggs
Price: 31
Time: 09.08.08
5)
Name: juice
Price: 19
Time: 30.11.08
MAGAZINE #33
Address
City: Volgograd
Street: Potemkina
House: 57
Products
1)
Name: butter
Price: 34
Time: 10.07.08
2)
Name: meat
Price: 29
Time: 27.08.09
3)
Name: milk
Price: 19
Time: 27.03.08
4)
Name: eggs
Price: 38
Time: 13.02.08
5)
Name: juice
Price: 14
Time: 16.05.08
Any key to continue...
Выбранный пункт меню: 3
Enter product’s name:
Вводим eggs
*New list created successfully! Press any key…*
Возврат в меню.
Выбранный пункт меню: 4
MAGAZINE #25
Address
City: Moscow
Street: Lenina
House: 14
Products
1)
Name: butter
Price: 17
Time: 12.05.08
2)
Name: meat
Price: 19
Time: 22.07.09
3)
Name: milk
Price: 25
Time: 17.03.08
4)
Name: eggs
Price: 47
Time: 07.08.08
5)
Name: juice
Price: 12
Time: 24.11.08
MAGAZINE #666
Address
City: Kiev
Street: Gagarina
House: 47
Products
1)
Name: butter
Price: 22
Time: 12.05.08
2)
Name: meat
Price: 29
Time: 26.02.09
3)
Name: milk
Price: 22
Time: 26.07.08
4)
Name: eggs
Price: 56
Time: 31.10.08
Press any key to continue…
Выбранный пункт меню: 5
Enter path to file to write (ex. C:\\file.txt):
Вводим d:\eggs.dat
*File created successfully! Press any key…*
Возврат в меню.
Выбранный пункт меню: 6
Работа программы завершена.
Содержимое выходного файла (eggs.dat):
/* Начало файла */
25
Moscow
Lenina
14
butter
17
12.05.08
meat
19
22.07.09
milk
25
17.03.08
eggs
47
07.08.08
juice
12
24.11.08
756
Minsk
Zhukova
52
butter
19
07.04.08
meat
21
29.02.09
milk
23
01.11.09
eggs
33
09.10.08
juice
14
27.08.08
666
Kiev
Gagarina
47
butter
22
12.05.08
meat
29
26.02.09
milk
22
26.07.08
eggs
56
31.10.08
2>