README.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. This assignment asks you to solve problems using recursion. You need
  2. to submit answer04.c through Blackboard. You can submit only
  3. answer04.c. If you change pa04.c or pa04.h, your change will be
  4. ignored in grading.
  5. The teaching staff have office hours everyday Monday to Friday. If you
  6. need help, please go to the office hours.
  7. The teaching staff will not debug your code. Do not send your program
  8. to the teaching staff and ask them to debug for you.
  9. Copying code is strictly forbidden. If you copy code, you will
  10. receive F in this course and your case will be reported to the
  11. department.
  12. The deadline is enforced by Blackboard. If Blackboard marks your
  13. submission as late, your submission will not be graded and you will
  14. receive zero. Being late by one second is late.
  15. You can submit as many times as you wish before the deadline. If you
  16. want to resubmit, you need to withdraw your earlier submission first.
  17. Blackboard does not keep the files you withdraw. If you withdraw
  18. without resubmission, it would be impossible for the teaching staff to
  19. retrieve an earlier version for grading.
  20. Submission by email is not accepted.
  21. You should not think that a program is correct if it can generate a
  22. correct output for one test case. It is possible that the program
  23. fails for some other test cases. Moreover, a program may be wrong
  24. even if it can generate a correct output. A program may have some
  25. hidden problems. The most common hidden problems are
  26. * memory leaks
  27. and
  28. * invalid memory accesses
  29. The indexes for an array start from 0, not 1. If an array has n
  30. elements, valid indexes are 0, 1, ..., n-1. If you use n as an index,
  31. the program may appear working in some cases. However, the program is
  32. wrong. Some tools can detect such problems. If such a problem is
  33. detected during grading, you will lose points.
  34. You will not receive 99% of the point if the program is "99% correct".
  35. If it is "99% correct", it is wrong. That "1%" mistake may crash your
  36. program during grading and you will receive zero.
  37. You should initialize all variables. If a variable is not
  38. initialized, its value is garbage and the program's behavior is
  39. undefined.
  40. If your program fails in grading, you will receive zero. It does not
  41. matter whether your program works when you test it.
  42. You will lose one point for each gcc warning message. If your program
  43. has any warning message, you should fix the problems and remove the
  44. warning message first. Do not ignore warning messages and think you
  45. can fix them later (after you "finish" debugging). In many cases, the
  46. warning messages indicate the bugs.
  47. Read your program line by line before you test it.
  48. If your program has any problem, read your program before you try to
  49. debug. You will not be able to debug your program by testing it.
  50. =============================================================
  51. This assignment asks you to solve the following problems:
  52. * partition a positive integer with different restrictions
  53. You should change only answer04.c. You can add more functions in
  54. that file. Do not modify pa04.h or pa04.c.
  55. Please check the sample outputs in expected directory for the formats.
  56. You can test your functions with your own input file.
  57. input file format:
  58. <method> <value to partition>
  59. methods:
  60. 1. All
  61. 2. Increasing
  62. 3. Decreasing
  63. 4. Odd
  64. 5. Even
  65. 6. OddAndEven
  66. 7. Prime
  67. usage: ./pa04 <input file>
  68. Example file "test.in" (the following line):
  69. 1 3
  70. Example execute command (on the following line):
  71. ./pa04 test.in
  72. Your program must provide a general solution. Suppose n is the number
  73. of the elements in the original set, you cannot do anything like
  74. if (n == 3)
  75. {
  76. ...
  77. }
  78. if (n == 4)
  79. {
  80. ...
  81. }
  82. if (n == 5)
  83. {
  84. ...
  85. }
  86. This solution is not general. You will receive zero if you do so.
  87. -----------------------------------------------------
  88. Partitioning an integer means breaking the integer into the sum of
  89. some positive integers (including the integer itself).
  90. For example, 3 can be partitioned into
  91. 1 + 1 + 1
  92. 1 + 2
  93. 2 + 1
  94. 3
  95. Your solution must be general. You will receive zero if you hard code
  96. the answers for some cases, something like the following:
  97. if (n == 3)
  98. {
  99. printf("1 + 1 + 1\n");
  100. printf("1 + 2\n");
  101. printf("2 + 1\n");
  102. printf("3\n");
  103. }
  104. if (n == 4)
  105. {
  106. printf("1 + 1 + 1 + 1\n");
  107. printf("1 + 1 + 2\n");
  108. printf("1 + 2 + 1\n");
  109. printf("1 + 3\n");
  110. ...
  111. }
  112. This solution is not general and you will receive zero.
  113. ===========================================================
  114. Please read and understand all files given to you, including
  115. pa04.h
  116. pa04.c
  117. answer04.c
  118. To find more make commands, type
  119. make help
  120. To test your program, type
  121. make testall
  122. You do not need to understand makefile.