Algorithms and C language
Homework 2
To be returned by Monday 10 June 2019
- You should send the source file and the executable file.
- Please, do not forget: your name, surname, your Tianjin code and UQAC code, as
well as your e-mail address if you have one.
- At most two names can appear on your homework copy.
Write a C program that does the following tasks each of which should be written as a
function:
1. Create a file FP that contains a set of persons structured each in a name of at most 30
characters and an integer to denote the age of that person.
2. Create a linked list from file FP in which each node has the following structure
struct node {
char name[20];
int age;
struct node *ptrnext;
}
3. Print on screen all the elements of the list each on a single line.
4. Delete all the occurrences to make the linked list contain only distinct names.
5. Print on screen all the elements of the list each on a line
6. Input from the keyboard a set of elements such that:
- If the new element already exists in the list, then insert it into the end of
the list.
- It the new element does not exist in the list, then insert it into the position
just before the element with the nearest age from below.
7. Print on screen all the elements of the resulted list each on a single line.
8. Print all the elements of the resulted list into file FP.
9. In the end of your program, destroy your linked list.
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。