`
;; *) sign=1 continue ;; esac done exit 1
fi #if 5, make sure if the user wanna overwrite the file that has been created. cp $1 $2 if [ \then
echo \else
echo \fi #if 6, to check if there's sth wrong.
2.Makefile与C编程:本题考查Makefile的编写,C语言基础,以及编程规范性。编写C程序,完成单向链表反转功能,如:输入字符串Hello World,每个链表节点仅保存一个字符,最后将整个单向链表的顺序反转,并返回链表头指针。 要求:(1)建立四个文件:main.c reverse.c reverse.h Makefile; (2)main.c仅包含main()函数,负责输入字符串,调用反转函数; (3)在合适的文件中声明你的数据结构,对函数进行声明; (4)在合适的文件中存储反转函数的实现;
(5)编写Makefile,并使用GCC通过Makefile对你写的程序实现编译,连接,形成最终可以执行的文件。
-------------------------------------------
main.c文件 -------
#include \
#include \#include \
char main(void)
{char *i;
NODE *head,*p,*q;
head=NULL;
printf(\
`
for(i=1;i<=n;i++) {
p=(NODE *)malloc(sizeof(NODE)); p->;data=i; if(head==NULL) q=head=p; else{ q->;next=p; q=p; } }
q->;next=NULL;
for(p=head;p;p=p->;next) p=f(head);
printf(\return 0;
} ------ reverse.c -------
#include \
NODE *f(NODE *head) {
NODE *p,*q; NODE *h; h=NULL;
for(q=head,p=head->;next;p;q=p,p=p->;next) {
if(h==NULL){ h=q;
h->;next=NULL; } else{
`
q->;next=h; h=q; } }
q->;next=h; h=q; return h;
} ---------- reverse.h ----------
typedef struct NODE { char data;
struct NODE *next;
}NODE; --------- Makefile ---------
edit: main.o reverse.o cc -o edit main.o reverse.o
main.o : main.c reverse.h cc -c main.c
reverse.o : reverse.c reverse.h cc -c reverse.c
clean:
rm edit main.o reverse.o
百度搜索“70edu”或“70教育网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,70教育网,提供经典教育范文LINUX大作业(北邮信息工程2024年春)(3)在线全文阅读。
相关推荐: