1~9不断循环
class Solution {
public:
int addDigits(int num) {
return (num-1) + 1;
}
};
本文介绍了一种简洁的C++算法,用于计算1到9之间的数字不断循环相加的问题。通过`Solution`类中的`addDigits`函数实现,该函数接收一个整数参数并返回经过特定计算后的结果。
1~9不断循环
class Solution {
public:
int addDigits(int num) {
return (num-1) + 1;
}
};
1万+
9272
848

被折叠的 条评论
为什么被折叠?