本文整理汇总了C++中Solution::addDigits方法的典型用法代码示例。如果您正苦于以下问题:C++ Solution::addDigits方法的具体用法?C++ Solution::addDigits怎么用?C++ Solution::addDigits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solution
的用法示例。
在下文中一共展示了Solution::addDigits方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Solution sol;
cout << sol.addDigits(38) << endl;
cout << sol.addDigits(99) << endl;
cout << sol.addDigits(1) << endl;
cout << sol.addDigits(100) << endl;
return 0;
}
示例2:
TEST(Solution, Main)
{
Solution solution;
EXPECT_EQ(0, solution.addDigits(0));
EXPECT_EQ(1, solution.addDigits(10));
EXPECT_EQ(1, solution.addDigits(1));
EXPECT_EQ(1, solution.addDigits(1000000));
// 123456789 => 45
// 45 => 9
EXPECT_EQ(9, solution.addDigits(123456789));
}
示例3: main
int main()
{
Solution s;
cout << s.addDigits(1853) << endl;
return 0;
}
示例4: main
int main()
{
Solution s;
printf("%d\n", s.addDigits(22222));
return 0;
}
示例5: main
int main(){
Solution sol;
int seed = 38;
cout << "Adding the digits of " << seed << ": "
<< sol.addDigits(seed) // << sol.addDigits2(seed)
<< endl;
return 0;
}
示例6: main
int main() {
Solution s;
for (int i=0; i<9999999; ++i) {
int result = s.addDigits(i);
printf("%d --> %d, div9=%d, mod9=%d\n", i, result, i/9, i%9);
}
return 0;
}
示例7: main
/*************************在leetcode上直接提交以上代码即可******************************/
int main()
{
int num;
cin >> num;
Solution solu;
int add_digit = solu.addDigits(num);
cout << add_digit << endl;
return 0;
}
示例8: main
int main()
{
Solution sol;
//int i = sol.singleNumber(vector<int>({1,1,2,3,3}));
int test_i = sol.addDigits(1352324);
TreeNode* t = new TreeNode(1);
t->left = new TreeNode(2);
vector<int> t_i = sol.preorderTraversal(t);
bool is_happyNum = sol.isHappy(4);
return 0;
}
示例9: main
int main(){
Solution s ;
// int i = 1;
cout<<s.addDigits(22)<<endl;
return 1;
}
示例10: main
int main(void)
{
printf("%d\n", g.addDigits(10));
system("pause");
}
示例11: main
int main(void) {
Solution solution;
cout << solution.addDigits(38) << "\tPassed\n";
cout << "\nPassed All\n";
return 0;
}
示例12: main
int main(){
Solution solu;
int result = solu.addDigits(12333);
cout << result <<endl;
return 0;
}
示例13: main
int main(){
Solution solution;
cout<<solution.addDigits(38)<<endl;
return 0;
}
示例14: CHECK
#include "../catch.h"
#include "solution.h"
TEST_CASE("Add Digits", "addDigits") {
Solution sln;
CHECK(sln.addDigits(0) == 0);
CHECK(sln.addDigits(1) == 1);
CHECK(sln.addDigits(10) == 1);
CHECK(sln.addDigits(98) == 8);
CHECK(sln.addDigits(666) == 9);
CHECK(sln.addDigits(964) == 1);
}
示例15: main
int main()
{
Solution solution;
std::cout << solution.addDigits(38) << std::endl;
return 0;
}