IO-02. 整數四則運算

來源:互聯網
上載者:User

標籤:style   blog   color   io   java   ar   strong   div   sp   

本題要求編寫程式,計算2個正整數的和、差、積、商並輸出。題目保證輸入和輸出全部在整型範圍內。

輸入格式:

輸入在一行中給出2個正整數A和B。

輸出格式:

在4行中按照格式“A 運算子 B = 結果”順序輸出和、差、積、商。

輸入範例:

3 2

輸出範例:

3 + 2 = 53 - 2 = 13 * 2 = 63 / 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. 整數四則運算

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.