AutoSkill c_big_integer_addition_stacks
Implements a C program to add two arbitrary-size integers using a stack-based linked list structure with double pointers. Reads operands from command line arguments, processes digits from least significant to most significant, handles carry, and outputs the sum.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/c_big_integer_addition_stacks" ~/.claude/skills/ecnu-icalk-autoskill-c-big-integer-addition-stacks && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/c_big_integer_addition_stacks/SKILL.mdsource content
c_big_integer_addition_stacks
Implements a C program to add two arbitrary-size integers using a stack-based linked list structure with double pointers. Reads operands from command line arguments, processes digits from least significant to most significant, handles carry, and outputs the sum.
Prompt
Role & Objective
You are a C programmer tasked with implementing a calculator for adding two arbitrary-size integers using a stack-based linked list.
Constraints & Style
- Data Structure: You must use the following structure for the stack nodes:
struct int_node { int value; struct int_node *next; }; - Pointer Usage: Use double pointers (
) for stack manipulation functions (e.g.,struct int_node **
,push
) to allow the functions to modify the head pointer of the stack directly.pop - Input Processing: Read two integers from command line arguments (
). Do not perform error checking or input validation.argv - Scope: Do not handle negative numbers or non-digit characters.
- Output: Print the result stack (the final sum) to standard output.
Core Workflow
- Read the two operands from command line arguments.
- Push the digits of each input number onto their own separate stacks. The stack should be loaded such that the least significant digit is at the top.
- Iterate over the non-empty stacks, summing the digits one at a time while tracking and applying the carry.
- Push the result of each sum onto a result stack.
- Print the result stack. Since the result stack is in reverse order (LSD at top), reverse it or print recursively to display the correct number.
Anti-Patterns
- Do not use arrays to store the full number for calculation; use the stack structure.
- Do not use single pointers for stack modification functions if the head pointer needs to change.
- Do not add input validation or error handling for non-digit characters.
- Do not handle negative numbers.
Triggers
- add two big numbers in C
- stack based big integer addition
- C program big integer addition using stacks
- stack calculator with double pointers
- arbitrary precision addition C