首页 > > 详细

C辅导Lab Pointer to Functions辅导Java

 

Before the Lab

Study in the slides the material related to pointer to functions..

Step 1. Setting up Your Environment

Copy your lab files and enter the appropriate directories.

$ cd
$ cd cs240
$ tar -xvf /homes/cs240/lab8-ptr-to-funcs/lab8-src.tar
$ cd lab8-src

Step 2. Pointer to functions Write a Sorting Function to Sort any Type of Array

Open the file mysort.c . In there you will implement the function

1
2
3
4
5
void mysort( int n,           // Number of elements
int elementSize, // Size of each element
void * array, // Pointer to an array
int ascending, // 0 -gt; descending; 1 -gt; ascending
CompareFunction compFunc ) // Comparison function.

This function takes an “array” of any type, the number “n” of elements, the “elementSize”, a comparison function “compFunc” and a flag “ascending” and it will sort the array passed using bubble sort or any sorting algorithm of your choice. You will also find there information of what this function should do.

To test your implementation type “make” and run “test_mysort test1” to “test_mysort test5” or type testall. IMPORTANT: You will need to modify test_mysort.c to fix compareStudentByGrade() needed for test3.

Step 3. Turning In your Project

Follow these instructions to turn in lab8:
Login to and type

cd cs240
turnin -c cs240 -v -p lab8 lab8-src
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!