AutoSkill C++ BigInt Class with Reverse Vector Storage
Implement a C++ BigInt class for arbitrarily large integers using a vector of digits stored in reverse order (least significant digit first). The class must support construction from string, conversion to string, and addition.
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_GLM4.7/c-bigint-class-with-reverse-vector-storage" ~/.claude/skills/ecnu-icalk-autoskill-c-bigint-class-with-reverse-vector-storage-a01c4d && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/c-bigint-class-with-reverse-vector-storage/SKILL.mdsource content
C++ BigInt Class with Reverse Vector Storage
Implement a C++ BigInt class for arbitrarily large integers using a vector of digits stored in reverse order (least significant digit first). The class must support construction from string, conversion to string, and addition.
Prompt
Role & Objective
You are a C++ developer tasked with implementing a BigInt class to handle arbitrarily large integers that exceed standard type limits.
Operational Rules & Constraints
- Data Structure: Use
to store individual digits of the number.std::vector<int> - Storage Order: Store digits in reverse order (least significant digit at index 0). For example, the integer 321 must be stored as
.{1, 2, 3} - Class Interface: You must implement the class with the following specific structure:
class BigInt { public: BigInt(std::string s); // convert string to BigInt std::string to_string() const; // get string representation void add(BigInt b); // add another BigInt to this one private: std::vector<int> digits; }; - Constructor Logic: In
, iterate through the input string from the last character to the first. Convert each character to an integer digit usingBigInt(std::string s)
and push it into thestatic_cast<int>(s[i] - '0')
vector.digits - String Conversion Logic: In
, iterate through theto_string() const
vector in reverse (using reverse iteratorsdigits
andrbegin
) to construct the output string so the most significant digit appears first.rend - Addition Logic: Implement the
method to perform long addition. Handle carry propagation correctly. Ensure theadd(BigInt b)
vector grows if a final carry remains after processing the most significant digit.digits
Anti-Patterns
- Do not store digits in standard order (most significant digit first).
- Do not use standard integer types (int, long long) to store the full number value.
- Do not omit the
qualifier on theconst
method.to_string
Triggers
- create a BigInt class in C++
- implement big integer using vector
- C++ reverse vector number storage
- BigInt addition with carry