本人也是大学生一个,第一次写博客,想记录一下我在大学遇到的程序,不会的,和搞懂了的。懂了之后,写出来分享给大家看,我感觉很多人写的都是c语言,但是我学的是c++啊,虽然看个半懂,但还是C++看着顺眼一点。希望那些和我遇到同样问题的人在看了这个程序之后可以解决你们的相关问题。
当时在写这个程序的时候,我栽在了怎么输入一个字符就把它累加起来,但是我没学到结束的条件,如果有知道的也可以告诉我哦。所以后来我换了一种写法,就是把数字字符一连串的输入进来,之后再处理。
我写的程序可能繁琐,但是我目前只学了这些内容,以后学了更多的,会把相关的代码也贴在这里。
题目如下:
time limit per test
2 seconds
memory limit per test
265 megabytes
input
standard input
output
standard output
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-digit?
Input
The first line contains the only