注意字符串的输入方法char a[100] = { 0 };scanf("%s", &a);Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every...
分类:
其他好文 时间:
2015-12-03 21:04:19
阅读次数:
213
题目:Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3...
分类:
其他好文 时间:
2015-12-03 07:11:38
阅读次数:
145
Reverse digits of an integer. Returns 0 when the reversed integer overflows (signed 32-bit integer).ExampleGiven x = 123, return 321Given x = -123, re...
分类:
其他好文 时间:
2015-12-01 07:09:05
阅读次数:
131
一个小规律public class Solution { public int addDigits(int num) { if (num < 9) { return num; } return num % 9 == 0 ? 9 :...
分类:
其他好文 时间:
2015-11-30 07:18:50
阅读次数:
246
循环求解方式不再赘述。O(1)时间的方法:公式:(num-1)%9 + 1;假设num为一个五位数,num = (a + b + c + d + e) + (a * 9999 + b * 999 + c * 99 + d * 9),将num对9取余后,结果为a + b + c + d + e。反复执...
分类:
其他好文 时间:
2015-11-29 16:16:48
阅读次数:
118
Superprime RibButchering Farmer John's cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across...
分类:
其他好文 时间:
2015-11-28 15:07:18
阅读次数:
151
Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3 + ...
分类:
其他好文 时间:
2015-11-28 11:50:50
阅读次数:
125
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
分类:
其他好文 时间:
2015-11-28 06:31:42
阅读次数:
122
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at...
分类:
其他好文 时间:
2015-11-27 23:35:14
阅读次数:
174
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at...
分类:
其他好文 时间:
2015-11-26 14:43:22
阅读次数:
120