一行输入正整数
,不含前导零。
输出
的科学计数法表示 ``
``。
299792458
3.0*10^8
602214129000000000000000
6.0*10^23
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String n = scanner.nextLine();
scanner.close();
int len = n.length();
// 指数c初始为位数减1
int c = len - 1;
// 第一位数字a
int a = n.charAt(0) - '0';
// 第二位数字d2
int d2 = n.charAt(1) - '0';
// 第三位数字d3,用于四舍五入判断
int d3 = n.charAt(2) - '0';
// 判断是否需要对d2进位
int carry = d3 >= 5 ? 1 : 0;
d2 += carry;
// 处理d2进位后可能等于10的情况
if (d2 == 10) {
d2 = 0;
a += 1;
// 处理a进位后可能等于10的情况
if (a == 10) {
a = 1;
c += 1;
}
}
// 按格式输出结果
System.out.printf("%d.%d*10^%d\n", a, d2, c);
}
}
#include <iostream>
#include <vector>
using namespace std;
int main()
{
string num;
cin >> num;
int n1 = num[0] - '0';
int n2 = num[1] - '0';
int n3 = num[2] - '0';
int len = num.size() - 1;
if (n3 >= 5)
{
n2 ++ ;
if (n2 == 10)
{
n1 ++ ;
n2 = 0;
if (n1 == 10)
{
n1 = 1;
len ++ ;
}
}
}
printf("%d.%d*10^%d", n1, n2, len);
} #include <iostream>
using namespace std;
int main() {
string s;
cin >> s;
int k, a, b;
a = s[0] - '0';
b = s[1] - '0';
k = s.size() - 1;
if (s[2] - '0' >= 5) {
b = (s[1] - '0') + 1;
}
if (b == 10 ) {
a = (s[0] - '0') + 1;
b = 0;
if (a == 10) {
a = 1;
b = 0;
k = s.size();
cout << a << '.' << b << '*' << 10 << '^' << k;
return 0;
}
k = s.size() - 1;
cout << a << '.' << b << '*' << 10 << '^' << k;
return 0;
}
cout << a << '.' << b << '*' << 10 << '^' << k;
return 0;
}
// 64 位输出请用 printf("%lld")
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 0x3f3f3f3f3f3f3f3f;
void solve(){
string s;cin>>s;
int cnt=s.length()-1;
if(s[2]>='5'){
if(s[1]=='9'){
s[1]='0';
if(s[0]=='9'){
s[0]='1';
cnt++;
}
else s[0]++;
}
else s[1]++;
}
cout<<s[0]<<"."<<s[1]<<"*10^"<<cnt;
}
signed main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int t=1;
// cin>>t;
while(t--){
solve();
}return 0;
} #include <iostream>
using namespace std;
#include<cmath>
#include<string>
#include<iomanip>
int main() {
string s;
cin>>s;
string a,a1,a2;
bool jinwei=0;// 进位标志 防止99.9变为100.0出错
a=string(s,0,2)+'.'+string(1,s[2]); //注意 判断的是第三位是否四舍五入
double rounda=round(stod(a));
rounda=rounda/10;
if(rounda==10){
rounda=1;
jinwei=1;
}
cout<<fixed<<setprecision(1)<<rounda;
int c=s.size()-1;
if(jinwei==1){
c++;
}
cout<<"*10^"<<c;
}
// 64 位输出请用 printf("%lld") import sys
N = input()
c=len(N)-1
if int(N[2])>=5:
b= int(N[1])+1
else:
b = int(N[1])
if b == 10:
b=0
a = int(N[0])+1
else:
a=int(N[0])
if a == 10:
a = 1
b = 0
c+=1
print(f'{a}.{b}*10^{c}')