Перейти к содержимому

Заказ на фриланс · Разработка и IT

Implement Four C Programming Assignments

  • Бюджет: 2 696 ₽ – 22 470 ₽
  • Раздел: Разработка и IT
  • Опубликован: (МСК)

Assignment description

The project consists of four independent C programs: luhn, vigenere, a stack/queue implementation, and queens.

luhn validates a numeric string of 2–32 ASCII digits using the Luhn mod-10 checksum. It processes the string from right to left, keeps the rightmost digit unchanged, doubles every second digit, and subtracts 9 from any doubled value greater than 9. The program preserves leading zeros by treating the input as characters rather than converting it to an integer. It prints OK for a valid checksum or FAIL otherwise, each followed by a newline, and returns 0. Invalid argument count, length, or non-digit input is reported to stderr with a nonzero return code. The Luhn algorithm checks only a checksum and does not verify whether a payment card exists or can be used; only synthetic data is used.

vigenere implements the historical Vigenère cipher with the interface vigenere enc|dec KEY TEXT. The key must be a nonempty sequence of ASCII letters and is interpreted case-insensitively, with A/a representing shift 0 through Z/z representing shift 25. The key repeats cyclically, but advances only when an ASCII letter in the text is processed. Encryption and decryption preserve letter case, leave all other bytes unchanged, and print the result followed by a newline. Empty text is valid, while an invalid mode, empty key, non-letter key characters, or wrong argument count produces an error on stderr and a nonzero exit code. No external cryptographic libraries are used.

The stack and queue component implements two fixed-capacity integer containers of 16 elements. The stack uses LIFO behavior, while the queue uses FIFO behavior and is implemented as a circular array so removal does not shift remaining elements. Each structure has its own type and interface providing initialization, insertion, removal, and a function returning the current element count. Insertion and removal return success or failure; removed values are returned through an output parameter. Removing from an empty structure leaves both the structure and output value unchanged, while inserting into a full structure leaves its contents unchanged. Both structures support zero and negative values, use constant-time operations, and can be compiled separately with gcc -c.

queens solves the classic eight-queens problem using recursive backtracking. It places one queen per row and tests candidate columns from left to right, rejecting positions that conflict with an already placed queen in the same column or either diagonal. State is restored during backtracking so every arrangement is found exactly once. The program supports three modes: --first prints the first solution, --all prints every solution separated by blank lines and ends with count: 92, and --count prints only 92. Rotations and reflections count as separate solutions. The solver logic is separated from argument handling and output formatting into at least two source modules with headers. The program validates arguments, handles output and allocation errors, releases dynamic resources if used, and returns 0 on success or nonzero on invalid usage.

Похожие заказы

Заказы для программистов на фрилансе · Все свежие заказы