首页 > 其他 > 详细

IO-02. 整数四则运算

时间:2014-09-05 17:50:41      阅读:297      评论:0      收藏:0      [点我收藏+]

本题要求编写程序,计算2个正整数的和、差、积、商并输出。题目保证输入和输出全部在整型范围内。

输入格式:

输入在一行中给出2个正整数A和B。

输出格式:

在4行中按照格式“A 运算符 B = 结果”顺序输出和、差、积、商。

输入样例:

3 2

输出样例:

3 + 2 = 5
3 - 2 = 1
3 * 2 = 6
3 / 2 = 1
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();
             System.out.println(a+" + "+b+" = "+(a+b));
             System.out.println(a+" - "+b+" = "+(a-b));
             System.out.println(a+" * "+b+" = "+(a*b));
             System.out.println(a+" / "+b+" = "+(a/b));
         }
}

 



IO-02. 整数四则运算

原文:http://www.cnblogs.com/lsgcoder101/p/3958272.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!