题解 | 单组_一维数组

单组_一维数组

https://www.nowcoder.com/practice/f3a0631c336d42099103c187a9c65e62

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n= in.nextInt();
        int [] a=new int [n];
        long sum=0;
        for(int i=0;i<n;i++){
            a[i]=in.nextInt();
            sum=a[i]+sum;
        }
        System.out.print(sum);
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
吴offer选手:学到了,下次面试也放张纸在电脑上,不然老是忘记要说哪几个点
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务