题解 | 特殊的科学计数法

特殊的科学计数法

https://www.nowcoder.com/practice/ca0962879d3b40d8bb598fb9a905ac7a

#include <iostream>
#include <string>
using namespace std;

int main() {
    string n;
    cin>>n;
    int l=n.length(), e=l-1;
    int a=n[0]-'0', b=0;
    if(l>1) b=n[1]-'0';
    if(l>2 && n[2]>='5') b++;
    if(b==10){
        b=0;
        a++;
    }
    if(a==10){
        a=1;
        e++;
    }
    cout<<a<<'.'<<b<<"*10^"<<e<<endl;
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务