ISE 101 Projects J
ISE 101 Projects J
1.
1 Matrix operations (C)
2. Simple database (C)
3. Linked lists (C)
4. Game of numbers (python)
5. Multiple mp3 finder (python)
6. Matrix operations (python)
7. Ascii art generator (python)
8
8. Oth ll with
Othello ith GUI ((python)
th )
Project 1 ‐ Matrix operations
Due: 21/02/2008 17:00
This ffunction
Thi ti willill allocate
ll t memory ffor a matrix
t i structure.
t t
Then it will allocate memory for a matrix of size nrows x
ncols It returns the address of the structure
ncols. structure.
February 15, 2008 Lecture 1 2
Project 1 – Matrix operations
• Function 2:
void destroy_matrix(struct matrix_str*);
This function will free the allocated memoryy for the
elements of the matrix. Then it will free the memory
allocated for the struct.
• Function 3;
int compare_matrices(struct matrix_str*, struct
matrix str*);
matrix_str*);
This function compares the sizes and elements of the
matrices and returns 1 if they are equal, 0 if they are not
equal
• Any line starting with a “#” is a comment line, your program should not
process these lines
• First integer in the file is the number of records in the file
• Each record has 5 fields: student number
number, student name and surname
surname,
midterm grade, project grade, final grade.
• Fields are separated with semicolons.
• You should read these records from a file and populate structure array
Due: March 13, 2008 Project 2 2
Project 2
struct student_record {
long int id;
char name[128];
double midterm;
double project;
double final
};
Subroutine 1:
struct student_record *sr populate_from_file(char *filename,int *number_read);
This function should read the records from file with the passed “filename”, allocate enough
space for an structure array. Assign the student information to the structure, and return the
structure array pointer. Upon the return number_read should point to the number of records
read from the file.
file
If the number of records is more than the number given in the beginning of the file, the
subroutine should stop at the given number of records.
This subroutine should write the student records to the file with the p
passed “filename” usingg
the same format described (number of records, then the record fields seperated with
semicolons). Each line should contain one record. The function should return the number of
records written.
Subroutine 3:
struct student_record * search_by_id(struct student_record *sr, int number_of_records, int
id);
This subroutine should go through the student records searching for a student with the
passed id.
id The subroutine should return the address of the student record that matches the
passed id. If nothing matches it should return NULL.
Subroutine 5:
int compute_number_of_failing_students (struct student_record *sr, int number_of_records,
int passing_grade);
)
This subroutine calculate the total grades of all students. The total grade is calculated by
weighting
i hti midterm
idt b
by 0
0.2,
2 projects
j t b by 0
0.4,
4 andd fi
finall with
ith 0
0.4.
4 SSo a student
t d t who
h gott 30 ffrom
midterm, 50 from projects, and 80 from final should have total grade of
30*0.2+50*0.4+80*0.4=58. The subroutine should count the number of students whose total
grade is less than (not less than or equal) the passed “passing grade” and return this number.
curPtr
position=‐1 position=1
img=Image.open(‘beyaz.jpg')
nrow,ncol=img.size
asciichars =["@", "#", "+", "*", ";", ":", ",", ".", "`", " "]
#asciichars =["#", "@", "Q", "X", "W", "O", "K", "p", "i"]
fid=open(‘beyaz.html','w');
fid.write('<HTML>\n')
fid.write('<echo>\n')
fid.write('<body bgcolor=#8080ff>\n')
fid.write('<font color=white>\n')
fid.write('<pre style="font: 9px/9px Courier New;">\n')
#
# Go through each element of the image and write one of the
# ascii chars according to the value of the image pixel.
# For highest values (brighter pixels) put @
# For lowest values (darkest pixels) put white space
#
#
print img.getpixel((100,100))
fid.write('</pre>\n')
fid.close();
Othello with Graphics
• Write reversi or othello on a 8x8 board
• For game rules see
http://en wikipedia org/wiki/Reversi
http://en.wikipedia.org/wiki/Reversi
• Game will be played between 2 players, NOT against
computer
p
• For a simple GUI see the simpleGUI.py
• simpleGUI.py uses a graphic library named graphics.py
• For more information on the graphics library see
graphics.pdf at Ninova
• This project is OPTIONAL and will count for 50% of your
final exam grade.
• You have to turn it in before taking your ISE101 final
exam.