#include <iostream>
#include <iomanip>
int main(){
//std::endl : places a new line character on the output stream.
// This is identical to placing '\n' on the output stream.
std::cout << "Hello";
std::cout << "World";
std::cout << std::endl;
std::cout << "-------------" << std::endl;
std::cout << "Hello" << std::endl;
std::cout << "World" << std::endl;
std::cout << std::endl;
std::cout << "Hello\n";
std::cout << "World\n";
//===================================================================
std::cout << std::endl;
//std::flush : flushes the output buffer to its final destination.
std::cout << "This is a nice message...." << std::endl << std::flush;
//After this std::flush, we're sure that at this line, the message has been sent
//to the stream. This may be important in some applications.
//===================================================================
std::cout << std::endl;
//std::setw() : Adjusts the field with for the item about to be printed.
//The setw() manipulator only affects the next value to be printed.
std::cout << "Unformatted table : " << std::endl;
std::cout << "Daniel" << " " << "Gray" << " 25" << std::endl;
std::cout << "Stanley" <<" " << "Woods" << " 33" << std::endl;
std::cout << "Jordan" << " " << "Parker" << " 45" << std::endl;
std::cout << "Joe" << " " << "Ball" << " 21" << std::endl;
std::cout << "Josh" << " " << "Carr" << " 27" << std::endl;
std::cout << "Izaiah" << " " << "Robinson" << " 29" << std::endl;
std::cout << std::endl;
std::cout << "Formatted table : " << std::endl;
std::cout << std::setw(10) << "Lastname" << std::setw(10) << "Firstname" << std::setw(5) << "Age" << std::endl;
std::cout << std::setw(10) << "Daniel" << std::setw(10) << "Gray" << std::setw(5) << "25" << std::endl;
std::cout << std::setw(10) << "Stanley" << std::setw(10) << "Woods" << std::setw(5) << "33" << std::endl;
std::cout << std::setw(10) << "Jordan" << std::setw(10) << "Parker" << std::setw(5) << "45" << std::endl;
std::cout << std::setw(10) << "Joe" << std::setw(10) << "Ball" << std::setw(5) << "21" << std::endl;
std::cout << std::setw(10) << "Josh" << std::setw(10) << "Carr" << std::setw(5) <<"27" << std::endl;
std::cout << std::setw(10) << "Izaiah" << std::setw(10) << "Robinson" << std::setw(5) << "29" << std::endl;
std::cout << std::endl;
std::cout << "Formatted table with variables: " << std::endl;
int col_width{14};
std::cout << std::setw(col_width) << "Lastname" << std::setw(col_width) << "Firstname" << std::setw(col_width/2) << "Age" << std::endl;
std::cout << std::setw(col_width) << "Daniel" << std::setw(col_width) << "Gray" << std::setw(col_width/2) << "25" << std::endl;
std::cout << std::setw(col_width) << "Stanley" << std::setw(col_width) << "Woods" << std::setw(col_width/2) << "33" << std::endl;
std::cout << std::setw(col_width) << "Jordan" << std::setw(col_width) << "Parker" << std::setw(col_width/2) << "45" << std::endl;
std::cout << std::setw(col_width) << "Joe" << std::setw(col_width) << "Ball" << std::setw(col_width/2) << "21" << std::endl;
std::cout << std::setw(col_width) << "Josh" << std::setw(col_width) << "Carr" << std::setw(col_width/2) <<"27" << std::endl;
std::cout << std::setw(col_width) << "Izaiah" << std::setw(col_width) << "Robinson" << std::setw(col_width/2) << "29" << std::endl;
//===================================================================
std::cout << std::endl;
//Justify : Values can be justified in their fields. There are three manipulators
// for adjusting the justification: left, right, and internal.
//right justified
std::cout << std::endl;
std::cout << "Right justified table(default) : " << std::endl;
col_width = 20;
std::cout << std::right;
std::cout << std::setw(col_width) << "Lastname" << std::setw(col_width) << "Firstname" << std::setw(col_width/2) << "Age" << std::endl;
std::cout << std::setw(col_width) << "Daniel" << std::setw(col_width) << "Gray" << std::setw(col_width/2) << "25" << std::endl;
std::cout << std::setw(col_width) << "Stanley" << std::setw(col_width) << "Woods" << std::setw(col_width/2) << "33" << std::endl;
std::cout << std::setw(col_width) << "Jordan" << std::setw(col_width) << "Parker" << std::setw(col_width/2) << "45" << std::endl;
std::cout << std::setw(col_width) << "Joe" << std::setw(col_width) << "Ball" << std::setw(col_width/2) << "21" << std::endl;
std::cout << std::setw(col_width) << "Josh" << std::setw(col_width) << "Carr" << std::setw(col_width/2) <<"27" << std::endl;
std::cout << std::setw(col_width) << "Izaiah" << std::setw(col_width) << "Robinson" << std::setw(col_width/2) << "29" << std::endl;
//Left justified
std::cout << std::endl;
std::cout << "Left justified table : " << std::endl;
col_width = 20;
std::cout << std::left;
std::cout << std::setw(col_width) << "Lastname" << std::setw(col_width) << "Firstname" << std::setw(col_width/2) << "Age" << std::endl;
std::cout << std::setw(col_width) << "Daniel" << std::setw(col_width) << "Gray" << std::setw(col_width/2) << "25" << std::endl;
std::cout << std::setw(col_width) << "Stanley" << std::setw(col_width) << "Woods" << std::setw(col_width/2) << "33" << std::endl;
std::cout << std::setw(col_width) << "Jordan" << std::setw(col_width) << "Parker" << std::setw(col_width/2) << "45" << std::endl;
std::cout << std::setw(col_width) << "Joe" << std::setw(col_width) << "Ball" << std::setw(col_width/2) << "21" << std::endl;
std::cout << std::setw(col_width) << "Josh" << std::setw(col_width) << "Carr" << std::setw(col_width/2) <<"27" << std::endl;
std::cout << std::setw(col_width) << "Izaiah" << std::setw(col_width) << "Robinson" << std::setw(col_width/2) << "29" << std::endl;
//Internal justified : sign is left justified , data is right justified
std::cout << std::endl;
std::cout << "Internal justified : " << std::endl;
std::cout << std::right;
std::cout << std::setw(10) << -123.45 << std::endl;
std::cout << std::internal;
std::cout << std::setw(10) << -123.45 << std::endl;
//===================================================================
std::cout << std::endl;
//setfill
std::cout << std::endl;
std::cout << "Table with fill characters : " << std::endl;
col_width = 20;
std::cout << std::left;
std::cout << std::setfill('*'); // The fill character
std::cout << std::setw(col_width) << "Lastname" << std::setw(col_width) << "Firstname" << std::setw(col_width/2) << "Age" << std::endl;
std::cout << std::setw(col_width) << "Daniel" << std::setw(col_width) << "Gray" << std::setw(col_width/2) << "25" << std::endl;
std::cout << std::setw(col_width) << "Stanley" << std::setw(col_width) << "Woods" << std::setw(col_width/2) << "33" << std::endl;
std::cout << std::setw(col_width) << "Jordan" << std::setw(col_width) << "Parker" << std::setw(col_width/2) << "45" << std::endl;
std::cout << std::setw(col_width) << "Joe" << std::setw(col_width) << "Ball" << std::setw(col_width/2) << "21" << std::endl;
std::cout << std::setw(col_width) << "Josh" << std::setw(col_width) << "Carr" << std::setw(col_width/2) <<"27" << std::endl;
std::cout << std::setw(col_width) << "Izaiah" << std::setw(col_width) << "Robinson" << std::setw(col_width/2) << "29" << std::endl;
//===================================================================
std::cout << std::endl;
//boolalpha and noboolapha : control bool output format : 1/0 or true/false
bool condition {true};
bool other_condition {false};
std::cout << "conditi
没有合适的资源?快使用搜索试试~ 我知道了~
Source code for the C++ 20 Masterclass on udemy .zip
共988个文件
cpp:713个
h:224个
ixx:21个
需积分: 5 0 下载量 141 浏览量
2024-01-01
15:54:51
上传
评论
收藏 560KB ZIP 举报
温馨提示
Source code for the C++ 20 Masterclass on udemy
资源推荐
资源详情
资源评论
收起资源包目录
Source code for the C++ 20 Masterclass on udemy .zip (988个子文件)
main.cpp 14KB
main.cpp 10KB
main.cpp 9KB
main.cpp 8KB
main.cpp 8KB
main.cpp 7KB
main.cpp 7KB
main.cpp 7KB
main.cpp 6KB
main.cpp 6KB
main.cpp 6KB
main.cpp 5KB
main.cpp 5KB
main.cpp 5KB
main.cpp 5KB
main.cpp 5KB
main.cpp 5KB
main.cpp 5KB
main.cpp 5KB
doublecontainer.cpp 4KB
charcontainer.cpp 4KB
main.cpp 4KB
intcontainer.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
main.cpp 4KB
boxcontainer.cpp 4KB
main.cpp 4KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
number.cpp 3KB
number.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 3KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
boxcontainer.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
civilengineer.cpp 2KB
main.cpp 2KB
main.cpp 2KB
main.cpp 2KB
共 988 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
暮苍梧~
- 粉丝: 41
- 资源: 258
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功