当前位置:网站首页>电子协会 C语言 1级 29 、 对齐输出
电子协会 C语言 1级 29 、 对齐输出
2022-06-26 22:40:00 【dllglvzhenfeng】
电子协会 C语言 1级 29 、 对齐输出
C++代码 方法一
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int a, b, c;
cin >> a >> b >> c;
cout << setiosflags(ios::right) << setw(8) << a << " "
<< setiosflags(ios::right) << setw(8) << b << " "
<< setiosflags(ios::right) << setw(8) << c << endl;
return 0;
}
C++代码 方法二
/*
电子协会 C语言 1级 29 、 对齐输出 方法一
http://noi.openjudge.cn/ch0101/03/
读入三个整数,按每个整数占 8 个字符的宽度,右对齐输出它们。
输入
只有一行,包含三个整数,整数之间以一个空格分开。
输出
只有一行,按照格式要求依次输出三个整数,之间以一个空格分开。
样例输入
123456789 0 -1
样例输出
123456789 0 -1
*/
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
printf("%8d %8d %8d",a,b,c);
return 0;
}电子协会 C语言 1级 29 、 对齐输出 方法三
/*
电子协会 C语言 1级 29 、 对齐输出 方法三
http://noi.openjudge.cn/ch0101/03/
读入三个整数,按每个整数占 8 个字符的宽度,右对齐输出它们。
输入
只有一行,包含三个整数,整数之间以一个空格分开。
输出
只有一行,按照格式要求依次输出三个整数,之间以一个空格分开。
样例输入
123456789 0 -1
样例输出
123456789 0 -1
*/
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
cout<<setw(8)<<a<<" "<<setw(8)<<b<<" "<<setw(8)<<c<<endl;
return 0;
}电子协会 C语言 1级 29 、 对齐输出 方法四
/*
电子协会 C语言 1级 29 、 对齐输出 方法四
http://noi.openjudge.cn/ch0101/03/
读入三个整数,按每个整数占 8 个字符的宽度,右对齐输出它们。
输入
只有一行,包含三个整数,整数之间以一个空格分开。
输出
只有一行,按照格式要求依次输出三个整数,之间以一个空格分开。
样例输入
123456789 0 -1
样例输出
123456789 0 -1
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%8d %8d %8d\n",a,b,c);
return 0;
}python3代码
"""
1.1编程基础之输入输出 03 对齐输出
http://noi.openjudge.cn/ch0101/03/
https://blog.csdn.net/yigezzchengxuyuan/article/details/86582640
"""
a, b, c = map(int, input().split())
print(format(a, '>8'), format(b, '>8'), format(c, '>8'))电子协会 青少年软件编程等级考试 C语言历年真题
电子协会 青少年软件编程等级考试 C语言历年真题_dllglvzhenfeng的博客-CSDN博客
电子协会C语言 真题与模拟题
电子协会C语言 真题与模拟题_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 5 、判断能否被 3 ,5 ,7 整除
电子协会 C语言 1级 5 、判断能否被 3 ,5 ,7 整除_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 6 、骑车与走路
电子协会 C语言 1级 6 、骑车与走路_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 7 、画矩形
电子协会 C语言 1级 7 、画矩形_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 18 、计算邮资
电子协会 C语言 1级 18 、计算邮资_dllglvzhenfeng的博客-CSDN博客_csp试题
电子协会 C语言 1级 19 、求整数的和与均值
电子协会 C语言 1级 19 、求整数的和与均值_dllglvzhenfeng的博客-CSDN博客_电子学会c语言一级
电子协会 C语言 1级 21 、逻辑判断问题 输入三个数 a,b,c,输出最大者
电子协会 C语言 1级 21 、逻辑判断问题 输入三个数 a,b,c,输出最大者_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 23 、判断平闰年
电子协会 C语言 1级 23 、判断平闰年_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 24 、求最大公约数
电子协会 C语言 1级 24 、求最大公约数_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 28 、字符菱形
电子协会 C语言 1级 28 、字符菱形_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 29 、 对齐输出
边栏推荐
- Unity cloth system_ Cloth component (including dynamic call related)
- Unity: 脚本缺失 “The referenced script (Unknown) on this Behaviour is missing!“
- Unity布料系统_Cloth组件(包含动态调用相关)
- Yolov6: the fast and accurate target detection framework is open source
- 同花顺注册开户有没有什么风险?安全吗?
- Unity3d plug-in anyportrait 2D bone animation
- Restfultoolkitx of idea utility plug-in -- restful interface debugging
- Reading graph augmentations to learn graph representations (lg2ar)
- Weaving dream collection plug-ins are recommended to be free collection plug-ins
- 【LeetCode】1984. Minimum difference between highest and lowest of K scores
猜你喜欢

VB. Net class library - 4 screen shots, clipping

Restfultoolkitx of idea utility plug-in -- restful interface debugging

【图像处理基础】基于matlab GUI图像直方图均衡化系统【含Matlab源码 1924期】

Yolov6: the fast and accurate target detection framework is open source

开放世界机甲游戏-Phantom Galaxies

BS-GX-016基于SSM实现教材管理系统

Web crawler 2: crawl the user ID and home page address of Netease cloud music reviews

Bs-gx-016 implementation of textbook management system based on SSM

VB. Net class library to obtain the color under the mouse in the screen (Advanced - 3)

Using C to operate SQLSERVER database through SQL statement tutorial
随机推荐
从位图到布隆过滤器,C#实现
Which platform is the safest for buying stocks and opening accounts? Ask for sharing
leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】
在Flutter中解析复杂的JSON
Detailed explanation of nmap parameters
YOLOv6:又快又准的目標檢測框架開源啦
【老卫搞机】090期:键盘?主机?全功能键盘主机!
美术向的Unity动画知识
Centos7 compiling and installing redis
[mixed programming JNI] Part 12 jnaerator
Wechat applet is authorized to log in wx getUserProfile
树莓派初步使用
[bug feedback] the problem of message sending time of webim online chat system
[mixed programming JNI] Part 6: operation of strings and arrays in native
同花顺注册开户有没有什么风险?安全吗?
中金证券经理的开户链接开户买股票安全吗?有谁知道啊
Are there any risks for the top ten securities companies to register and open accounts? Is it safe?
数据治理啥都干
买股票通过中金证券经理的开户二维码开户资金是否安全?想开户炒股
Bs-gx-016 implementation of textbook management system based on SSM