8 solutions
-
2
这题可以使用
setw()函数。#include <iostream> #include <iomanip> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << setw(8) << a << " " << setw(8) << " " << setw(8) << b << " " << setw(8) << c << endl; return 0; }也可以使用
printf()函数。#include <cstdio> int main() { int a, b, c; scanf("%d %d %d", &a, &b, &c); printf("%8d %8d %8d\n", a, b, c); return 0; } -
1
#include #include // 这个头文件提供了设置输出格式的功能 using namespace std;
int main() { // 定义三个变量,用来存储输入的三个整数 int a, b, c;
// 从键盘读入三个整数,用空格分开 cin >> a >> b >> c; // 按要求输出:每个数占8个字符宽度,右对齐,中间用空格隔开 // setw(8) 就是设置宽度为8个字符的意思 cout << setw(8) << a << " " << setw(8) << b << " " << setw(8) << c; return 0;}
- 1
Information
- ID
- 4454
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 1
- Tags
- (None)
- # Submissions
- 1044
- Accepted
- 374
- Uploaded By