哪位大佬能把这段C语言代码转化为Python啊
本帖最后由 涛行 于 2020-12-2 15:51 编辑哪位大佬能把这段C语言代码转化为Python啊,小白转化时总出错#include<stdio.h>
#include<math.h>
int main()
{
int i = 0, j, k = 0, a, m, n;
scanf("%d", &n);
a = n;
for (; n > 0; n /= 10)
i++;
for (j = 1; j < i; j++)
k += 9 * j * pow(10, j - 1);
m = k + i * (a - pow(10, i - 1) + 1);
printf("%d\n", m);
return 0;
} 本帖最后由 pzx521521 于 2020-12-2 13:40 编辑
if __name__ == '__main__':
i = 0
k = 0
n = int(input())
a = n
while n > 0:
n = int(n / 10)
i += 1
j = 1
while j < i:
k += 9 * j * pow(10, j - 1)
j += 1
m = k + i * (a - pow(10, i - 1) + 1);
print(m, '\n')
本帖最后由 或跃在渊09 于 2020-12-2 13:54 编辑
i = 0
k = 0
n = int(input())
a = n
while n > 0:
i+=1
n = int(n / 10)
j = 1
while j < i:
k += 9 * j * pow(10, j - 1)
j += 1
m = k + i * (a - pow(10, i - 1) + 1)
print(m) 或跃在渊09 发表于 2020-12-2 13:50
i = 0
k = 0
n = int(input())
谢谢大佬 pzx521521 发表于 2020-12-2 13:25
if __name__ == '__main__':
i = 0
k = 0
谢谢大佬
页:
[1]