当前位置:网站首页>accumulator
accumulator
2022-04-22 08:36:00 【True question OK】
R7-6 accumulator (10 branch )
Please implement an accumulator . Input n Nonnegative integers , Output their and . 1<n<1000, And each number is <10000.
Input format :
The input consists of two lines . first line : Include an integer n, It means that there is a total of n Number . The second line : contain n It's an integer .
Output format :
Output n The number and .
sample input :
4
3 2 1 4
sample output :
10
java edition
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
double sum = 0;
for (int i = 0 ; i < n; i ++) {
double x = input.nextDouble();
sum += x;
}
System.out.printf("%.0f\n",sum);
}
}
c++ edition
#include<bits/stdc++.h>
using namespace std;
int main() {
int n,s=0; cin>>n;
for (int i=0 ;i < n;i++) {
int x; cin>>x;
s+=x;
if(i==n-1){
cout<<s<<endl;
break;
}
}
return 0;
}
版权声明
本文为[True question OK]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220743122423.html
边栏推荐
猜你喜欢

社会工程学之黑客七宗罪——傲慢(Hooking)

Cesium加载地形数据(cesiumlab制作地形数据),从源数据到地形服务

记录node中使用sequelize,自动生成表模型,链接操作数据库(以postgreSQL为例)

OSPF class IV, class V and class VII LSA details

235. 二叉搜索树的最近公共祖先(Easy)

Airtest installation and introduction

94. 二叉树的中序遍历(Easy)
![[Dahua cloud native] micro service chapter - service mode of five-star hotels](/img/fc/be18f39e4aa653efa8603ab63ff3f1.png)
[Dahua cloud native] micro service chapter - service mode of five-star hotels

SQL requirements processing - count the number of Mondays to Sundays in a given year

What do you know about the well-known public DNS servers in China
随机推荐
The map cutter can cut the picture into tile data. Its main purpose is to cut the high-definition satellite image into tile map. It can be used for offline map development based on Mercator coordinate
js学习笔记
机器学习笔记 - 行列式
【优麒麟】22.04 LTS版本即将发布,终极预告来袭,你准备好了吗?
微服务(分布式架构)
CPU的基本工作流程
Flutter Foundation
SmartTabLayout 简介
手把手教你实现RecyclerView的下拉刷新和上拉加载更多
The PS - EF query process PID in the shell script always returns an exception
Flutter基础
Spark SQL gets the element at an index of the array
Nacos Foundation (4): configure the external database of Nacos
jmu-枚举WeekDay
leaflet、cesium加载百度地图,加载自定义样式百度地图
客户端与服务器项目3
第1关:继承
Redis数据服务器/数据库/缓存(2022)
图片旋转
函数指针和指针函数