Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rmres authored Aug 18, 2020
1 parent 32cc7e0 commit 60ab2f2
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions simplearraysum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class Solution {

/*
* Complete the simpleArraySum function below.
*/
static int simpleArraySum(int[] ar) {
int sum = 0;
for (int i = 0; i < ar.Length; i++) {
sum = sum + ar[i];
}

return sum;
}

static void Main(string[] args) {
TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);

int arCount = Convert.ToInt32(Console.ReadLine());

int[] ar = Array.ConvertAll(Console.ReadLine().Split(' '), arTemp => Convert.ToInt32(arTemp))
;
int result = simpleArraySum(ar);

textWriter.WriteLine(result);

textWriter.Flush();
textWriter.Close();
}
}

0 comments on commit 60ab2f2

Please sign in to comment.