题目描述
读入三个整数a、b、c,交换它们中的数,使a存放b的值,b存放c的值,c存放a的值。
输入格式
输入共一行,三个数a,b,c
输出格式
输出共一行,三个数a,b,c
输入输出样例
输入 #1 复制
1 5 9
输出 #1 复制
5 9 1
说明/提示
保证a,b,c都在int范围之内
#include<iostream>
using namespace std;
int main(){
int a , b , c,t;
cin >> a >> b >> c;
t = a;
a = b ;
b = c;
c = t;
cout << a <<" "<< b <<" "<< c;
return 0;
}
Java题解:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
int t;
t = a;
a = b;
b = c;
c = t;
System.out.println(a+" "+b+" "+c);
}
}