實數的輸出和佔位---左對齊,右對齊,補空格
阿新 • • 發佈:2021-01-07
技術標籤:考研複試準備
O - 實數的輸出和佔位
Description
輸入一個實數,請你按如下要求輸出:
第一行按雙精度預設輸出,
第二行雙精度數輸出共佔 10 位,其中 3 位小數,右對齊,左補空格並在兩端新增星號包裹,
第三行雙精度數輸出共佔 10 位,其中 3 位小數,左對齊,右補空格並在兩端新增星號包裹。
Input
一個double範圍內的正實數 a 。
Output
共三行,按題目描述輸出。
Sample
Input
123.56789
Output
123.567890
- 123.568*
*123.568 *
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
double c;
cin>>c;
printf("%lf\n", c);
printf("*%10.3lf*\n", c);
printf("*%-10.3lf*\n", c);
return 0;
}