首页 > 试题广场 >

(a+b-c)*d的计算问题

[编程题](a+b-c)*d的计算问题
  • 热度指数:21878 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
\hspace{15pt}这是一个非常简单的题目,意在考察你编程的基础能力。千万别想难了哦。
\hspace{15pt}对于输入的四个整数 a, b, c, d,请计算表达式 (a+b-c)\times d 的值。

输入描述:
\hspace{15pt}在一行上输入四个整数 a, b, c, d \left(0 \lt a, b, c, d \lt 100\right)


输出描述:
\hspace{15pt}输出式子的计算结果。
示例1

输入

1 3 2 4

输出

8

说明

\hspace{15pt}在这个样例中,(1+3-2)\times4=2\times4=8
示例2

输入

4 3 2 1

输出

5

说明

\hspace{15pt}在这个样例中,(4+3-2)\times1=5\times1=5

备注:
本题已于下方时间节点更新,请注意题解时效性:
1. 2025-11-19 优化题面文本与格式,统一原题面的数据范围;新增一组样例。
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
        System.out.print((a+b-c)*d);
    }
}

发表于 2022-07-25 00:02:49 回复(0)
import java.util.*;

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 d = scanner.nextInt();
        int result = (a + b - c) * d;
        System.out.println(result);
    }
}

发表于 2022-06-24 14:15:12 回复(0)
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[4];
        while (sc.hasNext()) {
            for (int i = 0; i < 4; i++) {
                arr[i] = sc.nextInt();
            }
            int n = (arr[0] +arr[1] - arr[2]) * arr[3];
            System.out.print(n);
        }
    }
}

发表于 2022-06-16 14:25:48 回复(0)
import java.util.Scanner;

/**
 *
 * @Title          (a+b-c)*d的计算问题
 * @Description    <TODO>
 * 这是一个非常简单的题目,意在考察你编程的基础能力。千万别想难了哦。
 * 输入为一行,包括了用空格分隔的四个整数a、b、c、d(0 < a, b, c, d < 100,000)。输出为一行,为“(a+b-c)*d”的计算结果。
 * 输入描述:
 *      输入为一行,用空格分隔的四个整数a、b、c、d(0 < a, b, c, d < 100,000)。
 * 输出描述:
 *      输出为一行,为“(a+b-c)*d”的计算结果。
 * @author weijunfu<ijunfu @ qq.com>
 * @date 2022/03/16 10:05
 * @version 1.0.0
 *
 */

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();

        System.out.println((a+b-c)*d);

        in.close();
    }
}

发表于 2022-03-16 10:08:17 回复(0)
import java.util.Scanner;
public class Main{
    
    public static void main(String[] args){
        Scanner sin = new Scanner(System.in);
        int a = sin.nextInt();
        int b = sin.nextInt();
        int c = sin.nextInt();
        int d = sin.nextInt();
        
        System.out.println((a+b-c) * d);
    }
}

发表于 2022-01-27 20:17:29 回复(0)
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println((a + b - c) * d);
    }
}

发表于 2021-10-03 12:39:15 回复(0)
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();//读入一整行
        String[] s = input.split(" "); //以空格为届分割字符串,返回字符串数组
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		int c = Integer.parseInt(s[2]);
		int d = Integer.parseInt(s[3]);
        System.out.println((a+b-c)*d);
    }
}

发表于 2020-04-10 13:25:18 回复(0)

问题信息

上传者:牛客309119号
难度:
7条回答 2698浏览

热门推荐

通过挑战的用户

查看代码
(a+b-c)*d的计算问题