• 202008xx给定一个整数n(1<=n<=1000000000),要求从个位开始分离出它的每一位数字,从个位开始按照从低位到高位的顺序依次输出每一位数字(奥赛一本通p64 4题)


    //给定一个整数n(1<=n<=1000000000),要求从个位开始分离出它的每一位数字,从个位开始按照从低位到高位的顺序依次输出每一位数字(奥赛一本通p64 4题)
    //第一种解法 ,用到了stringstream,没用to_string,因为dev5.92版本不支持这个命令
    # include <iostream>
    # include <sstream>
    # include<cstdio>
    # include<string>
    using namespace std;
    int main()
    {
      stringstream ss;
      int b,c;
      int n;
      cin>>n;
      string str;
      //n的值先转换到ss里存储,再从ss赋给str
      ss<<n;
      ss>>str;
      b=str.length();
      // cout<<b<<endl;
      for(int e=b-1;e>=0;e--)
        {
        cout<<str.substr(e,1)+" ";
        }

      return 0;
    }

    //第二种解法
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int x;//用于存储求出来的值
      int n;
      cin>>n;
      do
        {
         x=n%10;
         n/=10;
         printf("%d ",x);
      }while(n>0);

      return 0;
    }

  • 相关阅读:
    p_value
    p_value
    第一次差异分析
    fdr
    rpkm&map
    rpkm&map
    s
    python数据处理小函数集合
    Jupyter Notebook 的快捷键
    自由度degree of freedom
  • 原文地址:https://www.cnblogs.com/whcsrj/p/13413603.html
Copyright © 2020-2023  润新知