One of the questions on the topic: A+B+C questions Python+Java

This is a very simple question designed to test your basic ability to program. Don't think it's hard. The input is one line, including three integers A, B, C separated by spaces (the data range is between -40 ~ 40). The output is one line, which is the calculation result of "A+B+C".


Python3 implementation

sum = 0
for n in input().split(' '):
    sum = sum + int(n)
    
print(sum)

Java language implementation:

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();
        
        System.out.println(a+b+c);
    }
}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324613895&siteId=291194637