ورود

نسخه کامل مشاهده نسخه کامل : کمک در مورد این پروژه



tdk50x
17-09-2009, 21:06
ا سلام
دوستان من بک گراند مهندسی کامپیوتر و برنامه نویسی با C رو ندارم. به دلایلی مجبور شدم درس Operating Systems رو بگیرم. متاسفانه 40 درصد نمره اختصاص به پروژه هایی داره که باید با C بنویسم. اولین پروژه مربوط به لیست های پیوندی میشه ظاهراً که اینجا کپی می کنم. انتظار ندارم که پروژه را برام انجام بدید اما به دلیل اینکه هیچی نمی دونم خواهش می کنم به صورت قدم به قدم بگید که باید چی کار کنم. الان دارم در مورد لیست های پیوندی مطالعه می کنم. لطفاً هر کی می تونه کمک کنه.


Project 1 description
 For this homework, you will be constructing a linked list
implementation in C using the templates provides above.
 You may need to modify the data structure (or add new data
structures) defined in list.h. However, you MAY NOT modify the
function defined in list.h. You may need to complete the function
bodies in list.c. You can add new functions into list.h.
 Create a test program to generate, populate and manipulate S
(S<M) linked list.
 Test data in the format of an M x N matrix will be provided.
 Toy example (10 x 11):
0 0 0 6 8 4 8 1 5 7 4
8 7 7 5 7 3 0 0 0 0 3
3 5 7 3 4 7 0 0 0 0 1
0 0 8 2 7 6 2 4 4 5 0
0 0 0 1 7 7 3 4 5 6 1
0 0 7 4 4 8 5 7 3 5 2
0 8 1 5 5 1 8 8 4 7 5
5 3 4 7 2 0 0 0 0 0 8
4 3 7 8 2 2 6 4 0 0 3
0 0 0 8 6 7 4 6 8 5 0

Project 1 Task
 Task Breaking down
1. Read the data into memory using file operations.
2. For the first S rows, put every element from the same row of the matrix into
a new linked list, so you will have S linked lists.
3. For every link list, implement the f function to calculate the walking
distances and record this distances into a linked list d.
4. Repeat the same operations for the rest rows (M-S).
5. Plot the curve with matlab about the values of d.
6. A written report is required.
 Due date: Sep. 28th, 2009.

Project 1 (Intlist.h)
#ifndef __intlist_h__
#define __intlist_h__
/* each entry in the list contains an int */
typedef struct intlist {
int datum;
struct intlist *next;
} INTLIST;
INTLIST *init_intlist( int n ); /* initializes the intlist with initial datum n */

int insert_intlist( INTLIST *lst, int n ); /* Inserts an int (n) into an intlist from the beginning*/
void list_append(INTLIST *list, void *datum); /* Inserts entry to the end of the list */
Void list_front(INTLIST *list); /*return the element at the front of the list, and remove it from the
list*/
void list_map( INTLIST *list, void (*f)(void *) ); /*Applies a function to each element of the list */
void list_delete( INTLIST *list ); /* Deletes (and frees) all entries in the list */
#endif

Project 1
 Intlist.c
#include <stdlib.h>
#include “intlist.h”
/* initializes the intlist with initial datum n */
INTLIST *init_intlist( int n ) {
INTLIST *lst;
lst = (INTLIST *)malloc(sizeof(INTLIST));
lst->datum = n;
lst->next = NULL;
return lst;
}
Project 1
 myprogram.c
#include <stdlib.h>
#include “intlist.h”
/* execution starts here */
int main() {
INTLIST *lst;
lst = init_intlist(1);

insert_intlist( lst, 2 );
free( lst );
return 0;
}

Project 1
 Makefile: putting everything together
CC=gcc
CFLAGS=-Wall -g
LIBS=-lreadline -lm
OBJS=intlist.o
INCLUDES=common.h
all: $(OBJS)

$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o myprogram
.c.o: $*.h $(INCLUDES)
$(CC) $(CFLAGS) -c $*.c
clean:
rm -f *.o myprogram

sin2x=2sinxcosx
18-09-2009, 09:49
سلام !
يعني کلا در مورد ليست پيوندي راهنمايي مي خواين يا فقط در مورد چگونگي کارکرد اين برنامه ؟
اگه هم قراره رو اين برنامه بحث شه لفطه برنامه رو داخل تگ html قرار بدين . يعني قبل از کدها کلمه [html] و بعد از اون [html/] رو بنويسين .

tdk50x
07-10-2009, 05:22
با تشکر
تونستم مشکل رو حل کنم.

ممنون