zoukankan      html  css  js  c++  java
  • 2373: 数字小游戏

    2373: 数字小游戏

    Time Limit: 1 Sec  Memory Limit: 128 MB
    Submit: 340  Solved: 128
    [Submit][Status][Web Board]

    Description

    游戏从一个整数S开始,只要它的位数多于1,就计算它各位的乘积,并且不断重复这个过程。比如:我们从95开始,9 × 5 = 45,45不是1位数,继续4 × 5 = 20.继续2 × 0 = 0.至此只有1位数,结束。
    再比如:如果从396开始
    3 × 9 × 6 = 162
    1 × 6 × 2 = 12
    1 × 2 = 2
    最后得到2。

    Input

    每行开始1个整数,表示起始值。最后以0结束。

    Output

    游戏从开始到结束的序列,从起始值开始。

    Sample Input

    95
    396 
    28 
    4 
    40
    0

    Sample Output

    95 45 20 0
    396 162 12 2
    28 16 6
    4
    40 0

    HINT

     

    Source


    #include<stdio.h> int main() { int n,a; int s=1; while(scanf("%d",&n)&&n!=0) { printf("%d ",n); if(n>=10) min(n); printf("\n"); } return 0; } int min(int n) { int a,s=1; while(n!=0) { a=n%10; s=s*a; n=n/10; } if(s>=10) { printf("%d ",s); min(s); } else printf("%d",s); }
  • 相关阅读:
    按钮常用
    MySQL常用Json函数
    MySQL所有函数及操作符
    MySQL常用时间函数
    MySQL常用聚合函数
    Shiro整合Spring
    Shiro集成Web
    Shrio授权验证详解
    Shrio认证详解+自定义Realm
    Shiro入门
  • 原文地址:https://www.cnblogs.com/mjn1/p/8433564.html
Copyright © 2011-2022 走看看