读入三个整数,按每个整数占8个字符的宽度,右对齐输出它们。
输入
只有一行,包含三个整数,整数之间以一个空格分开。
输出
只有一行,按照格式要求依次输出三个整数,之间以一个空格分开。
样例输入
123456789 0 -1
样例输出
123456789 0 -1
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
int a, b, c;
a = b = c = 0;
cin >> a;
cin >> b;
cin >> c;
cout <<setw(8) << a <<" " << setw(8) << b <<" " << setw(8) << c << endl;
system("pause");
return 0;
}
Java代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int a= input.nextInt();
int b= input.nextInt();
int c= input.nextInt();
System.out.printf("%8d %8d %8d",a,b,c);
}
}