c++ 格式输出
来源:互联网 发布:淘宝商家支付宝反现金 编辑:程序博客网 时间:2024/06/06 18:57
Your manager gave you a text file with many lines of numbers to format and print. For each row of space-separated doubles, format and print the numbers using the specifications in the Output Format section below.
Input Format
The first line contains an integer, , the number of test cases.
Each of the subsequent lines describes a test case as space-separated floating-point numbers: , , and , respectively.
Constraints
- Each number will fit into a double.
Output Format
For each test case, print lines containing the formatted , , and , respectively. Each , , and must be formatted as follows:
- : Strip its decimal (i.e., truncate it) and print its hexadecimal representation (including the prefix) in lower case letters.
- : Print it to a scale of decimal places, preceded by a or sign (indicating if it's positive or negative), right justified, and left-padded with underscores so that the printed result is exactly characters wide.
- : Print it to a scale of exactly nine decimal places, expressed in scientific notation using upper case.
Sample Input
1 100.345 2006.008 2331.41592653498
Sample Output
0x64 _______+2006.01 2.331415927E+03
#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <string>#include <map>#include <iomanip>#include <cstdio>#include <iostream>using namespace std;const int N = 700500;const int inf = 0x3f3f3f3f;int main(){ int T; scanf("%d", &T); cout<<setiosflags(ios::uppercase); cout<<setw(0xf)<<internal; while(T--) { double A; cin>>A; double B; cin>>B; double C; cin>>C; cout<<setw(0)<<showbase << hex << nouppercase << long(A) << endl; //setw(Number of characters to be used as field width.) hex 十六进制 //uppercase 大写 输出0X64 nouppercase 小写 cout << right << setfill ('_') << setw (15) << showpos << setprecision(2) << fixed << B << endl; //setfill(The new fill character for the stream)常与setw连用 //showpos 有正负号, 0没有正负号 //noshowpos 正常输出,无正负号 cout << uppercase << noshowpos << setprecision(9) << fixed << scientific << C << endl; //setprecision 保留有效位数 /*flag valueeffect when set fixedwrite floating-point values in fixed-point notation scientificwrite floating-point values in scientific notation. (none)write floating-point values in default floating-point notation. */ }}
0 0
- C语言格式输出
- C输出格式总结
- c语言 输出格式
- C格式输出
- C输出格式总结
- C语言输出格式
- C输出格式总结
- C输出格式总结
- C输出格式控制
- C输出格式控制
- c printf 输出格式
- C printf 格式输出
- c语言格式输出
- C语言输出格式
- c的格式输出“%”
- C/C++输出格式
- 【C++】输出格式
- 输出格式 c && c++
- Android-TextSize(px、sp)的坑
- 【Day22】mysql数据库的优化(一版)
- 前端优化实践总结
- 前端神器-sublime text3插件安装及使用
- 常见编码GBK、GB2312、UTF-8、ISO-8859-1的区别
- c++ 格式输出
- Jenkins+Maven+Git+Email+SSH实现持续自动化构建部署
- linux下,一个运行中的程序,究竟占用了多少内存
- BroadcastReceiver详解(二)
- FragmentTransaction管理的Fragment生命周期状态
- rabbitmq集群搭建
- C++ STL简单介绍
- php数组去重
- 部署Azkaban任务调度器demo