服务承诺





51Due提供Essay,Paper,Report,Assignment等学科作业的代写与辅导,同时涵盖Personal Statement,转学申请等留学文书代写。




私人订制你的未来职场 世界名企,高端行业岗位等 在新的起点上实现更高水平的发展




Assignment代写:Make files and Function Pointers
2018-04-08 来源: 51due教员组 类别: 更多范文
下面为大家整理一篇优秀的assignment代写范文- Make files and Function Pointers,供大家参考学习,这篇论文讨论了基础的C语言知识,涉及了make file相关的内容。
• The problems of this assignment must be solved in C.
• Your programs should have the input and output formatting according to the testcases listed after the problems.
Problem 4.1 Makefile (2 points) Presence assignment, due by 18:30 h today
Continue with your solution for Problem 3.4 in the following manner: write and upload a Make- file called “Makefile.txt” which has multiple targets and can be used to: 1) generate all object files corresponding to the source files, 2) generate executable code from the object files and 3) delete all files except source files.
Submit the three source files and the makefile called “Makefile.txt”. You can assume that the input will be valid.
Problem 4.2 Simple function pointers (2 points) Write a program that reads a string and then repeatedly reads a command (one character) from the standard input.
If you enter ’a’, then the string should be printed in uppercase on the standard output.
If you enter ’b’, then the string should be printed lowercase on the standard output.
If you enter ’c’, then lowercase characters should be printed uppercase and uppercase characters are printed lowercase on the standard output.
If you enter ’d’, then the program should quit the execution of the program.
Your main function or any other function where you read the commands may not contain any if or switch statements for mapping the command to which function should be called. Your main function should contain an endless while loop.
Implement the solution using function pointers. The original string should not be changed.
You can assume that the input will be valid.
Testcase 4.2: input
This is a String
a
b
c
b a d
number is 3 then the program should quit execution.
Your main function or any other function where you read the characters and the numbers may not contain any if or switch statements, but an endless while loop for repeated input.
Your program should use function pointers and for sorting you should use the function qsort() from stdlib.h.
You can assume that the input will be valid.
Problem 4.3
Quicksort with function pointers
(2 points) Write a program that sorts an array of n characters. After reading n and the values of the array from the standard input, the program reads an integer number and if this number is 1 then the sorting should be ascending, if the number is 2 then the sorting should be descending and if the
Testcase 4.2: output
THIS IS A STRING
this is a string
tHIS IS A sTRING
this is a string
THIS IS A STRING
Testcase 4.3: input
Testcase 4.3: output
edcba abcde
5 b d a e c 2 1 3
Problem 4.4
Bubblesort with function pointers
(4 points) Write a program that reads an array of the following structure and sorts the data in ascending
order by title or publication year using the bubblesort algorithm.
struct book {
char title[45];
int year;
};
Your program should read the number of books from the standard input followed by the array of data corresponding to the books. You should print the lists of sorted books in ascending order with respect to their title (alphabetical order) and with respect to their publication year. Within the sorting according to the title, note that if multiple books have the same title, then they should be sorted ascending with respect to their publication year. Within the sorting according to year, note that if multiple books have the same publication year, then they should be sorted alphabetically with respect to their name.
Instead of writing two sorting functions use function pointers such that you can implement a generic bubblesort function able to sort according to different criteria.
You can assume that the input will be valid.
The pseudocode of the bubblesort algorithm is the following:
repeat
swapped = false
for i = 1 to length(A) – 1 inclusive do: /∗ if this pair is out of order ∗/
if A[i-1] > A[i] then
/ ∗ swap them and remember swap( A[i-1], A[i] ) swapped = true
end if end for
until not swapped
Testcase 4.4: input
3
Algorithms and Data Structures
1993
Java Programming
2001
C Programming
1987
something
changed
∗ /
Testcase 4.4: output
By title:
{Algorithms and Data Structures, 1993}
{C Programming, 1987}
{Java Programming, 2001}
By year:
{C Programming, 1987}
{Algorithms and Data Structures, 1993}
{Java Programming, 2001}
51due留学教育原创版权郑重声明:原创assignment代写范文源自编辑创作,未经官方许可,网站谢绝转载。对于侵权行为,未经同意的情况下,51Due有权追究法律责任。主要业务有assignment代写、essay代写、paper代写、cs代写服务。
51due为留学生提供最好的assignment代写服务,亲们可以进入主页了解和获取更多assignment代写范文 提供作业代写服务,详情可以咨询我们的客服QQ:800020041。
