奋战杭电ACM(DAY9)1013
生活随笔
收集整理的這篇文章主要介紹了
奋战杭电ACM(DAY9)1013
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Digital Roots
#include <iostream> #include <string> using namespace std;int main() {string s;//溢出神煩哈!int m,n,i;while(cin >> s){ m=0;if(s[0]=='0') break;for(i=0; s[i]!='\0'; i++)m+=s[i]-'0';//轉換為int,巧妙!n= ((m%9==0)?9:(m%9));//這個判定很牛啊!!!只是不會證明……cout << n << endl;}return 0; }轉載于:https://www.cnblogs.com/ques3512012019/p/3295205.html
總結
以上是生活随笔為你收集整理的奋战杭电ACM(DAY9)1013的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 高阶函数之 reduce
- 下一篇: 关于jsp中jstl-core标签循环遍