OpenJudge1.1.03:对齐输出

03:对齐输出

原题链接

总时间限制: 1000ms 内存限制: 65536kB

描述

读入三个整数,按每个整数占8个字符的宽度,右对齐输出它们。

输入

只有一行,包含三个整数,整数之间以一个空格分开。

输出

只有一行,按照格式要求依次输出三个整数,之间以一个空格分开。

样例输入

123456789 0 -1

样例输出

123456789        0       -1

参考程序

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
	int a[3];
	int i,j;
	for ( i = 0 ; i < 3 ; i++)
		cin>>a[i];
	for ( i = 0 ; i < 3 ; i++)
		cout<<setw(8)<<a[i]<<" ";        //setw()表示要占多少个空格
	return 0;
}
//对齐输出时需要用到<iomanip>这个头文件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是每行的注释: ``` ListView{ // 定义一个名为 listView 的列表视图控件 id: listView // 控件的唯一标识符 anchors.left: parent.left // 控件与其父控件左对齐 anchors.right: parent.right // 控件与其父控件右对齐 anchors.top: row.bottom // 控件顶部与名为 row 的控件底部对齐 anchors.bottom: parent.bottom // 控件底部与其父控件底部对齐 clip: true // 列表内容超出控件边界时进行裁剪 spacing: 0 // 列表项之间的间距为0 snapMode: ListView.SnapToItem // 当滚动结束时,列表项会自动对齐到最近的项 ScrollBar.vertical: ScrollBar{ // 垂直滚动条 id: ver_scrollbar // 控件的唯一标识符 visible: true // 控件可见 } model: ListModel{ // 列表数据模型 id: listModel // 控件的唯一标识符 ListElement{ // 列表项元素 time: "2021-03-12\n12:21:31" // 时间属性 floor: 1 // 楼层属性 } } delegate: Rectangle{ // 列表项的委托组件 id: infoRec // 控件的唯一标识符 implicitHeight: 640 // 控件的默认高度 implicitWidth: 480 // 控件的默认宽度 width: listView.width // 控件的宽度等于列表视图控件的宽度 height: 120 // 控件的高度为120 Rectangle{ // 控件背景 id: dim // 控件的唯一标识符 anchors.fill: parent // 控件占满父控件 color: "grey" // 控件背景颜色 opacity: 0.3 // 控件背景透明度 z: 300 // 控件的 Z 轴坐标 visible: tableItem.hightLightIndex == index // 根据高亮索引决定控件可见性 } // 时间显示区域 Rectangle { // 时间显示区域 id: timeRec // 控件的唯一标识符 width: 90 // 控件宽度 color: index % 2 ? tableItem.evenRowColor : tableItem.oddRowColor // 控件背景颜色 anchors.left: parent.left // 控件左对齐 anchors.top: parent.top // 控件顶部对齐 anchors.topMargin: floorRec.height // 控件顶部外边距为楼层显示控件的高度 anchors.bottom: parent.bottom // 控件底部对齐 Text { // 时间文本控件 id: timeText // 控件的唯一标识符 text: time === undefined ? errorStr : time // 控件显示的文本内容 anchors.fill: parent // 控件占满父控件 color: "#002949" // 控件文本颜色 font.pixelSize: tableItem.timeFontPixelSize // 控件文本字体大小 font.family: tableItem.contentFontFamily // 控件文本字体 horizontalAlignment: Text.AlignHCenter // 控件文本水平对齐方式 verticalAlignment: Text.AlignVCenter // 控件文本垂直对齐方式 wrapMode: Text.WrapAnywhere // 控件文本自动换行模式 clip: true // 控件文本超出边界时进行裁剪 function replaceBlank(str){ // 替换文本中的空格为换行符的方法 let newStr = str newStr = newStr.replace(" ", "\n") } } } } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值